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
This commit is contained in:
@@ -1,26 +1,82 @@
|
|||||||
package domain
|
package domain
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
func TestDefaultAntigravityModelMapping_ImageCompatibilityAliases(t *testing.T) {
|
"github.com/stretchr/testify/assert"
|
||||||
t.Parallel()
|
)
|
||||||
|
|
||||||
cases := map[string]string{
|
func TestStatusConstants(t *testing.T) {
|
||||||
"gemini-2.5-flash-image": "gemini-2.5-flash-image",
|
assert.Equal(t, "active", StatusActive)
|
||||||
"gemini-2.5-flash-image-preview": "gemini-2.5-flash-image",
|
assert.Equal(t, "disabled", StatusDisabled)
|
||||||
"gemini-3.1-flash-image": "gemini-3.1-flash-image",
|
assert.Equal(t, "error", StatusError)
|
||||||
"gemini-3.1-flash-image-preview": "gemini-3.1-flash-image",
|
assert.Equal(t, "unused", StatusUnused)
|
||||||
"gemini-3-pro-image": "gemini-3.1-flash-image",
|
assert.Equal(t, "used", StatusUsed)
|
||||||
"gemini-3-pro-image-preview": "gemini-3.1-flash-image",
|
assert.Equal(t, "expired", StatusExpired)
|
||||||
}
|
}
|
||||||
|
|
||||||
for from, want := range cases {
|
func TestRoleConstants(t *testing.T) {
|
||||||
got, ok := DefaultAntigravityModelMapping[from]
|
assert.Equal(t, "admin", RoleAdmin)
|
||||||
if !ok {
|
assert.Equal(t, "user", RoleUser)
|
||||||
t.Fatalf("expected mapping for %q to exist", from)
|
}
|
||||||
}
|
|
||||||
if got != want {
|
func TestPlatformConstants(t *testing.T) {
|
||||||
t.Fatalf("unexpected mapping for %q: got %q want %q", from, got, want)
|
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")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user