moved to struct validation;

This commit is contained in:
Alex
2024-11-04 17:21:55 +01:00
parent 0fa57bfe75
commit fa10a0a507
15 changed files with 246 additions and 275 deletions

View File

@@ -221,8 +221,8 @@ func testLoginHandler(t *testing.T) (string, http.Cookie) {
}
assert.NotEmpty(t, loginCookie)
} else {
assert.Contains(t, response, "error")
assert.NotEmpty(t, response["error"])
assert.Contains(t, response, "errors")
assert.NotEmpty(t, response["errors"])
}
})
@@ -585,7 +585,7 @@ func testUpdateUser(t *testing.T, loginCookie http.Cookie) {
},
expectedStatus: http.StatusForbidden,
expectedErrors: []map[string]string{
{"field": "general", "key": "server.error.unauthorized_update"},
{"field": "user", "key": "server.error.unauthorized"},
},
},
{
@@ -623,6 +623,7 @@ func testUpdateUser(t *testing.T, loginCookie http.Cookie) {
t.Run(tt.name, func(t *testing.T) {
// Create a copy of the user and apply the updates
updatedUser := user
logger.Error.Printf("user to be updated: %+v", user.Licence)
tt.updateFunc(&updatedUser)
// Convert user to JSON
jsonData, err := json.Marshal(updatedUser)