veza/veza-backend-api/internal/services/admin_platform_service_test.go
2026-03-10 18:16:27 +01:00

68 lines
1.3 KiB
Go

package services
import (
"testing"
)
func TestNewAdminPlatformServiceNilLogger(t *testing.T) {
svc := NewAdminPlatformService(nil, nil)
if svc == nil {
t.Fatal("expected non-nil service")
}
if svc.logger == nil {
t.Fatal("expected non-nil logger (nop)")
}
}
func TestUpdateUserRoleValidation(t *testing.T) {
validRoles := map[string]bool{
"user": true, "creator": true, "premium": true,
"admin": true, "artist": true, "producer": true, "label": true,
}
tests := []struct {
role string
valid bool
}{
{"user", true},
{"creator", true},
{"premium", true},
{"admin", true},
{"artist", true},
{"producer", true},
{"label", true},
{"moderator", false},
{"superadmin", false},
{"", false},
}
for _, tt := range tests {
t.Run(tt.role, func(t *testing.T) {
if validRoles[tt.role] != tt.valid {
t.Errorf("role %q: expected valid=%v", tt.role, tt.valid)
}
})
}
}
func TestContentTypeValidation(t *testing.T) {
validTypes := map[string]bool{"track": true, "comment": true}
tests := []struct {
ctype string
valid bool
}{
{"track", true},
{"comment", true},
{"profile", false},
{"", false},
}
for _, tt := range tests {
t.Run(tt.ctype, func(t *testing.T) {
if validTypes[tt.ctype] != tt.valid {
t.Errorf("content type %q: expected valid=%v", tt.ctype, tt.valid)
}
})
}
}