Create new collections from my collections view
This commit is contained in:
@@ -104,3 +104,27 @@ func TestFetchModel[T any](t *testing.T, urlpath string, limit string, offset st
|
||||
}
|
||||
return w.Code, result
|
||||
}
|
||||
|
||||
func TestPostCall(t *testing.T, urlpath string, payload string) (int, uint) {
|
||||
router := TestSetup()
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
token := ConnectDemoUser(router)
|
||||
req, _ := http.NewRequest("POST", urlpath,
|
||||
strings.NewReader(payload))
|
||||
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
router.ServeHTTP(w, req)
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
return w.Code, 0
|
||||
}
|
||||
var parsed struct {
|
||||
ID uint
|
||||
}
|
||||
|
||||
err := json.Unmarshal(w.Body.Bytes(), &parsed)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
return w.Code, parsed.ID
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user