feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
package domain
|
|
|
|
|
|
test: add domain constants tests
Add tests for domain constant values:
- Status constants (active, disabled, error, etc.)
- Role constants (admin, user)
- Platform constants (anthropic, openai, gemini, etc.)
- Account type constants (oauth, apikey, bedrock, etc.)
- Redeem type constants
- PromoCode status constants
- Adjustment type constants
- Subscription type/status constants
- Model mapping verification
2026-05-29 21:04:33 +08:00
|
|
|
import (
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestStatusConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "active", StatusActive)
|
|
|
|
|
assert.Equal(t, "disabled", StatusDisabled)
|
|
|
|
|
assert.Equal(t, "error", StatusError)
|
|
|
|
|
assert.Equal(t, "unused", StatusUnused)
|
|
|
|
|
assert.Equal(t, "used", StatusUsed)
|
|
|
|
|
assert.Equal(t, "expired", StatusExpired)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRoleConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "admin", RoleAdmin)
|
|
|
|
|
assert.Equal(t, "user", RoleUser)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPlatformConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "anthropic", PlatformAnthropic)
|
|
|
|
|
assert.Equal(t, "openai", PlatformOpenAI)
|
|
|
|
|
assert.Equal(t, "gemini", PlatformGemini)
|
|
|
|
|
assert.Equal(t, "antigravity", PlatformAntigravity)
|
|
|
|
|
assert.Equal(t, "sora", PlatformSora)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccountTypeConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "oauth", AccountTypeOAuth)
|
|
|
|
|
assert.Equal(t, "setup-token", AccountTypeSetupToken)
|
|
|
|
|
assert.Equal(t, "apikey", AccountTypeAPIKey)
|
|
|
|
|
assert.Equal(t, "upstream", AccountTypeUpstream)
|
|
|
|
|
assert.Equal(t, "bedrock", AccountTypeBedrock)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestRedeemTypeConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "balance", RedeemTypeBalance)
|
|
|
|
|
assert.Equal(t, "concurrency", RedeemTypeConcurrency)
|
|
|
|
|
assert.Equal(t, "subscription", RedeemTypeSubscription)
|
|
|
|
|
assert.Equal(t, "invitation", RedeemTypeInvitation)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestPromoCodeStatusConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "active", PromoCodeStatusActive)
|
|
|
|
|
assert.Equal(t, "disabled", PromoCodeStatusDisabled)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAdjustmentTypeConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "admin_balance", AdjustmentTypeAdminBalance)
|
|
|
|
|
assert.Equal(t, "admin_concurrency", AdjustmentTypeAdminConcurrency)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSubscriptionTypeConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "standard", SubscriptionTypeStandard)
|
|
|
|
|
assert.Equal(t, "subscription", SubscriptionTypeSubscription)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSubscriptionStatusConstants(t *testing.T) {
|
|
|
|
|
assert.Equal(t, "active", SubscriptionStatusActive)
|
|
|
|
|
assert.Equal(t, "expired", SubscriptionStatusExpired)
|
|
|
|
|
assert.Equal(t, "suspended", SubscriptionStatusSuspended)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestDefaultAntigravityModelMapping(t *testing.T) {
|
|
|
|
|
assert.NotEmpty(t, DefaultAntigravityModelMapping)
|
|
|
|
|
|
|
|
|
|
// Check some key mappings exist
|
|
|
|
|
assert.Contains(t, DefaultAntigravityModelMapping, "claude-opus-4-6-thinking")
|
|
|
|
|
assert.Contains(t, DefaultAntigravityModelMapping, "gemini-2.5-flash")
|
|
|
|
|
assert.Contains(t, DefaultAntigravityModelMapping, "gpt-oss-120b-medium")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestDefaultBedrockModelMapping(t *testing.T) {
|
|
|
|
|
assert.NotEmpty(t, DefaultBedrockModelMapping)
|
|
|
|
|
|
|
|
|
|
// Check some key mappings exist
|
|
|
|
|
assert.Contains(t, DefaultBedrockModelMapping, "claude-opus-4-6-thinking")
|
|
|
|
|
assert.Contains(t, DefaultBedrockModelMapping, "claude-sonnet-4-6")
|
feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
}
|