test(users): add e2e tests for preferences apis

This commit is contained in:
hexxa 2021-10-17 20:11:35 +08:00 committed by Hexxa
parent fbe8708718
commit 2497968b82
5 changed files with 68 additions and 3 deletions

View file

@ -5,9 +5,9 @@ import (
"fmt"
"net/http"
"github.com/ihexxa/quickshare/src/db/userstore"
"github.com/ihexxa/quickshare/src/handlers"
"github.com/ihexxa/quickshare/src/handlers/multiusers"
"github.com/ihexxa/quickshare/src/db/userstore"
"github.com/parnurzeal/gorequest"
)
@ -162,3 +162,12 @@ func (cl *SingleUserClient) Self(token *http.Cookie) (*http.Response, *multiuser
}
return resp, selfResp, errs
}
func (cl *SingleUserClient) SetPreferences(prefers *userstore.Preferences, token *http.Cookie) (*http.Response, string, []error) {
return cl.r.Patch(cl.url("/v1/users/preferences")).
Send(multiusers.SetPreferencesReq{
Preferences: prefers,
}).
AddCookie(token).
End()
}