refactor: make createAuthenticatedUser accept interface and add user-only variant

This commit is contained in:
2025-12-27 17:43:19 +01:00
parent c04602d8d9
commit 3e9246c975

View File

@@ -398,7 +398,11 @@ type authenticatedUser struct {
Token string Token string
} }
func createAuthenticatedUser(t *testing.T, authService *services.AuthFacade, userRepo repositories.UserRepository, username, email string) *authenticatedUser { type authServiceInterface interface {
Login(username, password string) (*services.AuthResult, error)
}
func createAuthenticatedUser(t *testing.T, authService authServiceInterface, userRepo repositories.UserRepository, username, email string) *authenticatedUser {
t.Helper() t.Helper()
password := "SecurePass123!" password := "SecurePass123!"
@@ -429,6 +433,11 @@ func createAuthenticatedUser(t *testing.T, authService *services.AuthFacade, use
} }
} }
func createAuthenticatedUserOnly(t *testing.T, authService authServiceInterface, userRepo repositories.UserRepository, username, email string) *database.User {
t.Helper()
return createAuthenticatedUser(t, authService, userRepo, username, email).User
}
func uniqueTestUsername(t *testing.T, prefix string) string { func uniqueTestUsername(t *testing.T, prefix string) string {
return fmt.Sprintf("%s_%d_%d", prefix, time.Now().UnixNano(), len(t.Name())) return fmt.Sprintf("%s_%d_%d", prefix, time.Now().UnixNano(), len(t.Name()))
} }