forked from ebhomengo/niki
test(agent-kindbox-e2e): adding e2e test for "/agents/kindboxes" GET api
This commit is contained in:
parent
f3eeb124f9
commit
bf99fbed6d
|
@ -100,6 +100,31 @@ func getToken() (string, error) {
|
|||
return res.Tokens.AccessToken, nil
|
||||
}
|
||||
|
||||
// TODO: if anyone add a new kindbox for this agent, then this test will fail because count will change.
|
||||
// somehow we should link seed data with test data.
|
||||
// maybe not use sql seed data and create data in each test
|
||||
func TestAgent_KindBox_Get_All(t *testing.T) {
|
||||
kindBoxesCount := 1
|
||||
|
||||
url := "/agents/kindboxes"
|
||||
|
||||
teardown := setup.SeedMariaDB(testContainer.GetMariaDBConfig())
|
||||
t.Cleanup(teardown)
|
||||
|
||||
token, err := getToken()
|
||||
if err != nil {
|
||||
t.Fatalf("could not login: %s", err)
|
||||
}
|
||||
|
||||
resRecord := createRequest(http.MethodGet, url, token, nil)
|
||||
var res agentParam.GetAllResponse
|
||||
err = json.NewDecoder(resRecord.Body).Decode(&res)
|
||||
assert.NoError(t, err, "could not decode response body")
|
||||
|
||||
assert.Equal(t, http.StatusOK, resRecord.Code)
|
||||
assert.Equal(t, kindBoxesCount, len(res.AllKindBoxes))
|
||||
}
|
||||
|
||||
func createRequest(
|
||||
method string,
|
||||
url string,
|
||||
|
|
Loading…
Reference in New Issue