diff --git a/backend/src/server/routes/club_tag.go b/backend/src/server/routes/club_tag.go index 4d570b6b9..5940a5afd 100644 --- a/backend/src/server/routes/club_tag.go +++ b/backend/src/server/routes/club_tag.go @@ -9,7 +9,7 @@ import ( func ClubTag(router fiber.Router, clubTagService services.ClubTagServiceInterface) { clubTagController := controllers.NewClubTagController(clubTagService) - clubTags := router.Group("/:clubID/tags") + clubTags := router.Group("/tags") clubTags.Post("/", clubTagController.CreateClubTags) clubTags.Get("/", clubTagController.GetClubTags) diff --git a/backend/tests/api/club_tag_test.go b/backend/tests/api/club_tag_test.go index 4ed107c92..3aade82c2 100644 --- a/backend/tests/api/club_tag_test.go +++ b/backend/tests/api/club_tag_test.go @@ -1,209 +1,269 @@ package tests -// func AssertClubTagsRespDB(app TestApp, assert *assert.A, resp *http.Response, id uuid.UUID) { -// var respTags []models.Tag - -// // Retrieve the tags from the response: -// err := json.NewDecoder(resp.Body).Decode(&respTags) - -// assert.NilError(err) - -// // Retrieve the club connected to the tags: -// var dbClub models.Club -// err = app.Conn.First(&dbClub, id).Error - -// assert.NilError(err) - -// // Retrieve the tags in the bridge table associated with the club: -// var dbTags []models.Tag -// err = app.Conn.Model(&dbClub).Association("Tag").Find(&dbTags) - -// assert.NilError(err) - -// // Confirm all the resp tags are equal to the db tags: -// for i, respTag := range respTags { -// assert.Equal(respTag.ID, dbTags[i].ID) -// assert.Equal(respTag.Name, dbTags[i].Name) -// assert.Equal(respTag.CategoryID, dbTags[i].CategoryID) -// } -// } - -// func TestCreateClubTagsWorks(t *testing.T) { -// t.Parallel() -// appAssert, _, uuid := CreateSampleClub(t, nil) - -// // Create a set of tags: -// tagUUIDs := CreateSetOfTags(t, appAssert) - -// // Confirm adding real tags adds them to the club: -// TestRequest{ -// Method: fiber.MethodPost, -// Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), -// Body: SampleTagIDsFactory(&tagUUIDs), -// }.TestOnStatusAndDB(t, &appAssert, -// DBTesterWithStatus{ -// Status: fiber.StatusCreated, -// DBTester: func(app TestApp, assert *assert.A, resp *http.Response) { -// AssertClubTagsRespDB(app, assert, resp, uuid) -// }, -// }, -// ) - -// appAssert.Close() -// } - -// // func TestCreateClubTagsFailsOnInvalidDataType(t *testing.T) { -// t.Parallel() -// // _, _, uuid := CreateSampleClub(t, nil) - -// // // Invalid tag data types: -// // invalidTags := []interface{}{ -// // []string{"1", "2", "34"}, -// // []models.Tag{{Name: "Test", CategoryID: uuid.UUID{}}, {Name: "Test2", CategoryID: uuid.UUID{}}}, -// // []float32{1.32, 23.5, 35.1}, -// // } - -// // // Test each of the invalid tags: -// // for _, tag := range invalidTags { -// // malformedTag := *SampleTagIDsFactory(nil) -// // malformedTag["tags"] = tag - -// // TestRequest{ -// // Method: fiber.MethodPost, -// // Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), -// // Body: &malformedTag, -// // }.TestOnError(t, nil, errors.FailedToParseRequestBody).Close() -// // } -// // } - -// func TestCreateClubTagsFailsOnInvalidClubID(t *testing.T) { -// t.Parallel() -// badRequests := []string{ -// "0", -// "-1", -// "1.1", -// "foo", -// "null", -// } - -// for _, badRequest := range badRequests { -// TestRequest{ -// Method: fiber.MethodPost, -// Path: fmt.Sprintf("/api/v1/clubs/%s/tags", badRequest), -// Body: SampleTagIDsFactory(nil), -// }.TestOnError(t, nil, errors.FailedToValidateID).Close() -// } -// } - -// func TestCreateClubTagsFailsOnInvalidKey(t *testing.T) { -// t.Parallel() -// appAssert, _, uuid := CreateSampleClub(t, nil) - -// invalidBody := []map[string]interface{}{ -// { -// "tag": UUIDSlice{testUUID, testUUID}, -// }, -// { -// "tagIDs": []uint{1, 2, 3}, -// }, -// } - -// for _, body := range invalidBody { -// TestRequest{ -// Method: fiber.MethodPost, -// Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), -// Body: &body, -// }.TestOnError(t, &appAssert, errors.FailedToValidateClubTags) -// } - -// appAssert.Close() -// } - -// func TestCreateClubTagsNoneAddedIfInvalid(t *testing.T) { -// t.Parallel() -// appAssert, _, uuid := CreateSampleClub(t, nil) - -// TestRequest{ -// Method: fiber.MethodPost, -// Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), -// Body: SampleTagIDsFactory(nil), -// }.TestOnStatusAndDB(t, &appAssert, -// DBTesterWithStatus{ -// Status: fiber.StatusCreated, -// DBTester: func(app TestApp, assert *assert.A, resp *http.Response) { -// var respTags []models.Tag - -// err := json.NewDecoder(resp.Body).Decode(&respTags) - -// assert.NilError(err) - -// assert.Equal(len(respTags), 0) -// }, -// }, -// ) - -// appAssert.Close() -// } - -// func TestGetClubTagsFailsOnNonExistentClub(t *testing.T) { -// t.Parallel() -// TestRequest{ -// Method: fiber.MethodGet, -// Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid.New()), -// }.TestOnError(t, nil, errors.ClubNotFound).Close() -// } - -// func TestGetClubTagsReturnsEmptyListWhenNoneAdded(t *testing.T) { -// t.Parallel() -// appAssert, _, uuid := CreateSampleClub(t, nil) - -// TestRequest{ -// Method: fiber.MethodGet, -// Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), -// }.TestOnStatusAndDB(t, &appAssert, -// DBTesterWithStatus{ -// Status: 200, -// DBTester: func(app TestApp, assert *assert.A, resp *http.Response) { -// var respTags []models.Tag - -// err := json.NewDecoder(resp.Body).Decode(&respTags) - -// assert.NilError(err) - -// assert.Equal(len(respTags), 0) -// }, -// }, -// ) - -// appAssert.Close() -// } - -// func TestGetClubTagsReturnsCorrectList(t *testing.T) { -// t.Parallel() -// appAssert, _, uuid := CreateSampleClub(t, nil) - -// // Create a set of tags: -// tagUUIDs := CreateSetOfTags(t, appAssert) - -// // Add the tags: -// TestRequest{ -// Method: fiber.MethodPost, -// Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), -// Body: SampleTagIDsFactory(&tagUUIDs), -// }.TestOnStatus(t, &appAssert, fiber.StatusCreated) - -// // Get the tags: -// TestRequest{ -// Method: fiber.MethodGet, -// Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), -// }.TestOnStatusAndDB(t, &appAssert, -// DBTesterWithStatus{ -// Status: fiber.StatusOK, -// DBTester: func(app TestApp, assert *assert.A, resp *http.Response) { -// AssertClubTagsRespDB(app, assert, resp, uuid) -// }, -// }, -// ) - -// appAssert.Close() -// } +import ( + "fmt" + "net/http" + "testing" + + "github.com/GenerateNU/sac/backend/src/errors" + "github.com/GenerateNU/sac/backend/src/models" + h "github.com/GenerateNU/sac/backend/tests/api/helpers" + "github.com/goccy/go-json" + "github.com/gofiber/fiber/v2" + "github.com/google/uuid" +) + +func AssertClubTagsRespDB(eaa h.ExistingAppAssert, resp *http.Response, id uuid.UUID) { + var respTags []models.Tag + + err := json.NewDecoder(resp.Body).Decode(&respTags) + + eaa.Assert.NilError(err) + + var dbClub models.Club + + err = eaa.App.Conn.First(&dbClub, id).Error + + eaa.Assert.NilError(err) + + var dbTags []models.Tag + + err = eaa.App.Conn.Model(&dbClub).Association("Tag").Find(&dbTags) + + eaa.Assert.NilError(err) + + for i, respTag := range respTags { + eaa.Assert.Equal(respTag.ID, dbTags[i].ID) + eaa.Assert.Equal(respTag.Name, dbTags[i].Name) + eaa.Assert.Equal(respTag.CategoryID, dbTags[i].CategoryID) + } +} + +func AssertSampleClubTagsRespDB(eaa h.ExistingAppAssert, resp *http.Response, uuid uuid.UUID) { + AssertClubTagsRespDB(eaa, resp, uuid) +} + +func TestCreateClubTagsFailsOnInvalidDataType(t *testing.T) { + appAssert, _, clubUUID := CreateSampleClub(h.InitTest(t)) + + invalidTags := []interface{}{ + []string{"1", "2", "34"}, + []models.Tag{{Name: "Test", CategoryID: uuid.UUID{}}, {Name: "Test2", CategoryID: uuid.UUID{}}}, + []float32{1.32, 23.5, 35.1}, + } + + for _, tag := range invalidTags { + malformedTag := *SampleTagIDsFactory(nil) + malformedTag["tags"] = tag + + appAssert.TestOnError( + h.TestRequest{ + Method: fiber.MethodPost, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", clubUUID), + Body: &malformedTag, + Role: &models.Super, + }, + errors.FailedToParseRequestBody, + ) + } + + appAssert.Close() +} + +func TestCreateClubTagsFailsOnInvalidUserID(t *testing.T) { + appAssert := h.InitTest(t) + + badRequests := []string{ + "0", + "-1", + "1.1", + "foo", + "null", + } + + for _, badRequest := range badRequests { + appAssert = appAssert.TestOnError( + h.TestRequest{ + Method: fiber.MethodPost, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags", badRequest), + Body: SampleTagIDsFactory(nil), + Role: &models.Student, + }, + errors.FailedToValidateID, + ) + } + + appAssert.Close() +} + +func TestCreateClubTagsFailsOnInvalidKey(t *testing.T) { + appAssert, _, clubUUID := CreateSampleClub(h.InitTest(t)) + + invalidBody := []map[string]interface{}{ + { + "tag": UUIDSlice{uuid.New(), uuid.New()}, + }, + { + "tagIDs": []uint{1, 2, 3}, + }, + } + + for _, body := range invalidBody { + body := body + appAssert = appAssert.TestOnError( + h.TestRequest{ + Method: fiber.MethodPost, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", clubUUID), + Body: &body, + Role: &models.Student, + }, + errors.FailedToValidateClubTags, + ) + } + + appAssert.Close() +} + +func TestCreateClubTagsFailsOnNonExistentClub(t *testing.T) { + uuid := uuid.New() + + h.InitTest(t).TestOnErrorAndTester( + h.TestRequest{ + Method: fiber.MethodPost, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), + Body: SampleTagIDsFactory(nil), + Role: &models.Super, + }, + h.ErrorWithTester{ + Error: errors.ClubNotFound, + Tester: func(eaa h.ExistingAppAssert, resp *http.Response) { + var dbClub models.Club + + err := eaa.App.Conn.First(&dbClub, uuid).Error + + eaa.Assert.Assert(err != nil) + }, + }, + ).Close() +} + +func TestCreateClubTagsWorks(t *testing.T) { + appAssert, _, clubUUID := CreateSampleClub(h.InitTest(t)) + tagUUIDs, appAssert := CreateSetOfTags(appAssert) + + appAssert.TestOnStatusAndTester( + h.TestRequest{ + Method: fiber.MethodPost, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", clubUUID), + Body: SampleTagIDsFactory(&tagUUIDs), + Role: &models.Super, + }, + h.TesterWithStatus{ + Status: fiber.StatusCreated, + Tester: func(eaa h.ExistingAppAssert, resp *http.Response) { + AssertSampleClubTagsRespDB(eaa, resp, clubUUID) + }, + }, + ) + + appAssert.Close() +} + +func TestCreateClubTagsNoneAddedIfInvalid(t *testing.T) { + appAssert, _, clubUUID := CreateSampleClub(h.InitTest(t)) + + appAssert.TestOnStatusAndTester( + h.TestRequest{ + Method: fiber.MethodPost, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", clubUUID), + Body: SampleTagIDsFactory(nil), + Role: &models.Super, + }, + h.TesterWithStatus{ + Status: fiber.StatusCreated, + Tester: func(eaa h.ExistingAppAssert, resp *http.Response) { + var respTags []models.Tag + + err := json.NewDecoder(resp.Body).Decode(&respTags) + + eaa.Assert.NilError(err) + + eaa.Assert.Equal(len(respTags), 0) + }, + }, + ).Close() +} + +func TestGetClubTagsFailsOnNonExistentClub(t *testing.T) { + uuid := uuid.New() + + h.InitTest(t).TestOnErrorAndTester( + h.TestRequest{ + Method: fiber.MethodGet, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", uuid), + Role: &models.Super, + }, + h.ErrorWithTester{ + Error: errors.ClubNotFound, + Tester: func(eaa h.ExistingAppAssert, resp *http.Response) { + var dbClub models.Club + + err := eaa.App.Conn.First(&dbClub, uuid).Error + + eaa.Assert.Assert(err != nil) + }, + }, + ).Close() +} + +func TestGetClubTagsReturnsEmptyListWhenNoneAdded(t *testing.T) { + appAssert, _, clubUUID := CreateSampleClub(h.InitTest(t)) + + appAssert.TestOnStatusAndTester( + h.TestRequest{ + Method: fiber.MethodGet, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", clubUUID), + Role: &models.Student, + }, + h.TesterWithStatus{ + Status: fiber.StatusOK, + Tester: func(eaa h.ExistingAppAssert, resp *http.Response) { + var respTags []models.Tag + + err := json.NewDecoder(resp.Body).Decode(&respTags) + + eaa.Assert.NilError(err) + + eaa.Assert.Equal(len(respTags), 0) + }, + }, + ).Close() +} + +func TestGetClubTagsReturnsCorrectList(t *testing.T) { + appAssert, _, clubUUID := CreateSampleClub(h.InitTest(t)) + + tagUUIDs, appAssert := CreateSetOfTags(appAssert) + + appAssert.TestOnStatus( + h.TestRequest{ + Method: fiber.MethodPost, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", clubUUID), + Body: SampleTagIDsFactory(&tagUUIDs), + Role: &models.Student, + }, + fiber.StatusCreated, + ).TestOnStatusAndTester( + h.TestRequest{ + Method: fiber.MethodGet, + Path: fmt.Sprintf("/api/v1/clubs/%s/tags/", clubUUID), + Role: &models.Student, + }, + h.TesterWithStatus{ + Status: fiber.StatusOK, + Tester: func(eaa h.ExistingAppAssert, resp *http.Response) { + AssertSampleClubTagsRespDB(eaa, resp, clubUUID) + }, + }, + ).Close() +} diff --git a/backend/tests/api/helpers/auth.go b/backend/tests/api/helpers/auth.go index eb65640e3..f08767905 100644 --- a/backend/tests/api/helpers/auth.go +++ b/backend/tests/api/helpers/auth.go @@ -103,6 +103,7 @@ func (app *TestApp) authStudent() { "password": rawPassword, }, }) + if err != nil { panic(err) } diff --git a/backend/tests/api/user_tag_test.go b/backend/tests/api/user_tag_test.go index a7196e318..704987eca 100644 --- a/backend/tests/api/user_tag_test.go +++ b/backend/tests/api/user_tag_test.go @@ -55,12 +55,7 @@ func SampleTagIDsFactory(tagIDs *[]uuid.UUID) *map[string]interface{} { } } -func CreateSetOfTags(t *testing.T, appAssert *h.ExistingAppAssert) ([]uuid.UUID, *h.ExistingAppAssert) { - if appAssert == nil { - newAppAssert := h.InitTest(t) - appAssert = &newAppAssert - } - +func CreateSetOfTags(appAssert h.ExistingAppAssert) ([]uuid.UUID, h.ExistingAppAssert) { categories := SampleCategoriesFactory() categoryIDs := []uuid.UUID{} @@ -121,24 +116,21 @@ func CreateSetOfTags(t *testing.T, appAssert *h.ExistingAppAssert) ([]uuid.UUID, func AssertUserTagsRespDB(eaa h.ExistingAppAssert, resp *http.Response, id uuid.UUID) { var respTags []models.Tag - // Retrieve the tags from the response: err := json.NewDecoder(resp.Body).Decode(&respTags) eaa.Assert.NilError(err) - // Retrieve the user connected to the tags: var dbUser models.User + err = eaa.App.Conn.First(&dbUser, id).Error eaa.Assert.NilError(err) - // Retrieve the tags in the bridge table associated with the user: var dbTags []models.Tag err = eaa.App.Conn.Model(&dbUser).Association("Tag").Find(&dbTags) eaa.Assert.NilError(err) - // Confirm all the resp tags are equal to the db tags: for i, respTag := range respTags { eaa.Assert.Equal(respTag.ID, dbTags[i].ID) eaa.Assert.Equal(respTag.Name, dbTags[i].Name) @@ -151,19 +143,19 @@ func AssertSampleUserTagsRespDB(eaa h.ExistingAppAssert, resp *http.Response, uu } func TestCreateUserTagsFailsOnInvalidDataType(t *testing.T) { - // Invalid tag data types: + appAssert := h.InitTest(t) + invalidTags := []interface{}{ []string{"1", "2", "34"}, []models.Tag{{Name: "Test", CategoryID: uuid.UUID{}}, {Name: "Test2", CategoryID: uuid.UUID{}}}, []float32{1.32, 23.5, 35.1}, } - // Test each of the invalid tags: for _, tag := range invalidTags { malformedTag := *SampleTagIDsFactory(nil) malformedTag["tags"] = tag - h.InitTest(t).TestOnError( + appAssert = appAssert.TestOnError( h.TestRequest{ Method: fiber.MethodPost, Path: "/api/v1/users/:userID/tags/", @@ -172,11 +164,15 @@ func TestCreateUserTagsFailsOnInvalidDataType(t *testing.T) { TestUserIDReplaces: h.StringToPointer(":userID"), }, errors.FailedToParseRequestBody, - ).Close() + ) } + + appAssert.Close() } func TestCreateUserTagsFailsOnInvalidUserID(t *testing.T) { + appAssert := h.InitTest(t) + badRequests := []string{ "0", "-1", @@ -186,7 +182,7 @@ func TestCreateUserTagsFailsOnInvalidUserID(t *testing.T) { } for _, badRequest := range badRequests { - h.InitTest(t).TestOnError( + appAssert = appAssert.TestOnError( h.TestRequest{ Method: fiber.MethodPost, Path: fmt.Sprintf("/api/v1/users/%s/tags", badRequest), @@ -194,18 +190,20 @@ func TestCreateUserTagsFailsOnInvalidUserID(t *testing.T) { Role: &models.Student, }, errors.FailedToValidateID, - ).Close() + ) } + + appAssert.Close() } type UUIDSlice []uuid.UUID -var testUUID = uuid.New() - func TestCreateUserTagsFailsOnInvalidKey(t *testing.T) { + appAssert := h.InitTest(t) + invalidBody := []map[string]interface{}{ { - "tag": UUIDSlice{testUUID, testUUID}, + "tag": UUIDSlice{uuid.New(), uuid.New()}, }, { "tagIDs": []uint{1, 2, 3}, @@ -213,8 +211,7 @@ func TestCreateUserTagsFailsOnInvalidKey(t *testing.T) { } for _, body := range invalidBody { - body := body - h.InitTest(t).TestOnError( + appAssert = appAssert.TestOnError( h.TestRequest{ Method: fiber.MethodPost, Path: "/api/v1/users/:userID/tags/", @@ -223,8 +220,10 @@ func TestCreateUserTagsFailsOnInvalidKey(t *testing.T) { TestUserIDReplaces: h.StringToPointer(":userID"), }, errors.FailedToValidateUserTags, - ).Close() + ) } + + appAssert.Close() } func TestCreateUserTagsFailsOnNonExistentUser(t *testing.T) { @@ -250,10 +249,8 @@ func TestCreateUserTagsFailsOnNonExistentUser(t *testing.T) { } func TestCreateUserTagsWorks(t *testing.T) { - // Create a set of tags: - tagUUIDs, appAssert := CreateSetOfTags(t, nil) + tagUUIDs, appAssert := CreateSetOfTags(h.InitTest(t)) - // Confirm adding real tags adds them to the user: appAssert.TestOnStatusAndTester( h.TestRequest{ Method: fiber.MethodPost, @@ -298,12 +295,24 @@ func TestCreateUserTagsNoneAddedIfInvalid(t *testing.T) { } func TestGetUserTagsFailsOnNonExistentUser(t *testing.T) { - h.InitTest(t).TestOnError( + uuid := uuid.New() + + h.InitTest(t).TestOnErrorAndTester( h.TestRequest{ Method: fiber.MethodGet, - Path: fmt.Sprintf("/api/v1/users/%s/tags/", uuid.New()), + Path: fmt.Sprintf("/api/v1/users/%s/tags/", uuid), Role: &models.Super, - }, errors.UserNotFound, + }, + h.ErrorWithTester{ + Error: errors.UserNotFound, + Tester: func(eaa h.ExistingAppAssert, resp *http.Response) { + var dbUser models.User + + err := eaa.App.Conn.First(&dbUser, uuid).Error + + eaa.Assert.Assert(err != nil) + }, + }, ).Close() } @@ -331,11 +340,9 @@ func TestGetUserTagsReturnsEmptyListWhenNoneAdded(t *testing.T) { } func TestGetUserTagsReturnsCorrectList(t *testing.T) { - tagUUIDs, appAssert := CreateSetOfTags(t, nil) - - newAppAssert := *appAssert + tagUUIDs, appAssert := CreateSetOfTags(h.InitTest(t)) - newAppAssert.TestOnStatus( + appAssert.TestOnStatus( h.TestRequest{ Method: fiber.MethodPost, Path: "/api/v1/users/:userID/tags/", diff --git a/backend/tests/api/user_test.go b/backend/tests/api/user_test.go index 7f790c49e..54e8ad827 100644 --- a/backend/tests/api/user_test.go +++ b/backend/tests/api/user_test.go @@ -209,14 +209,15 @@ func TestUpdateUserWorks(t *testing.T) { } func TestUpdateUserFailsOnInvalidBody(t *testing.T) { + appAssert := h.InitTest(t) + for _, invalidData := range []map[string]interface{}{ {"email": "not.northeastern@gmail.com"}, {"nuid": "1800-123-4567"}, {"year": 1963}, {"college": "UT-Austin"}, } { - invalidData := invalidData - h.InitTest(t).TestOnErrorAndTester( + appAssert.TestOnErrorAndTester( h.TestRequest{ Method: fiber.MethodPatch, Path: "/api/v1/users/:userID", @@ -228,11 +229,15 @@ func TestUpdateUserFailsOnInvalidBody(t *testing.T) { Error: errors.FailedToValidateUser, Tester: TestNumUsersRemainsAt2, }, - ).Close() + ) } + + appAssert.Close() } func TestUpdateUserFailsBadRequest(t *testing.T) { + appAssert := h.InitTest(t) + badRequests := []string{ "0", "-1", @@ -246,15 +251,17 @@ func TestUpdateUserFailsBadRequest(t *testing.T) { (*slightlyDifferentSampleStudentJSON)["first_name"] = "John" for _, badRequest := range badRequests { - h.InitTest(t).TestOnError(h.TestRequest{ + appAssert.TestOnError(h.TestRequest{ Method: fiber.MethodPatch, Path: fmt.Sprintf("/api/v1/users/%s", badRequest), Body: slightlyDifferentSampleStudentJSON, Role: &models.Student, }, errors.FailedToValidateID, - ).Close() + ) } + + appAssert.Close() } func TestUpdateUserFailsOnIdNotExist(t *testing.T) {