Create new collections from my collections view

This commit is contained in:
2026-04-03 15:51:18 +02:00
parent b1bad80426
commit b48ab1e4de
11 changed files with 185 additions and 27 deletions

View File

@@ -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
}