diff --git a/delivery/http_server/end2end/agent_kindbox_test.go b/delivery/http_server/end2end/agent_kindbox_test.go index a9dd9df..2deebd0 100644 --- a/delivery/http_server/end2end/agent_kindbox_test.go +++ b/delivery/http_server/end2end/agent_kindbox_test.go @@ -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,