Add a view to see all books in a collection
This commit is contained in:
@@ -68,6 +68,23 @@ func TestBookPutCallWithDemoPayload(t *testing.T, payload string, bookId string,
|
||||
}
|
||||
}
|
||||
|
||||
func TestFetchOneModel[T any](t *testing.T, urlpath string, id string) (int, T) {
|
||||
router := TestSetup()
|
||||
|
||||
token := ConnectDemoUser(router)
|
||||
req, _ := http.NewRequest("GET", urlpath+"/"+id, nil)
|
||||
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
w := httptest.NewRecorder()
|
||||
router.ServeHTTP(w, req)
|
||||
|
||||
var result T
|
||||
err := json.Unmarshal(w.Body.Bytes(), &result)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
return w.Code, result
|
||||
}
|
||||
|
||||
func TestFetchModel[T any](t *testing.T, urlpath string, limit string, offset string) (int, T) {
|
||||
router := TestSetup()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user