package controlplane import ( "context" "testing" ) func TestGetTenantPreferencesWithoutTenantUsesConfiguredDefault(t *testing.T) { result, err := (&Store{}).GetTenantPreferences(context.Background(), "", 12_500_000) if err != nil { t.Fatal(err) } if !result.LowBalanceEnabled || result.LowBalanceThresholdMicros != 12_500_000 { t.Fatalf("unexpected defaults: %+v", result) } } func TestPreferenceValidationRejectsUnsafeValuesBeforeDatabaseAccess(t *testing.T) { store := &Store{} if _, err := store.SetDeveloperPreferences(context.Background(), SetDeveloperPreferencesInput{ TenantID: "tenant", DefaultModel: "same", FallbackModel: "same", }); err == nil { t.Fatal("expected identical default and fallback models to fail") } threshold := maxLowBalanceThresholdMicros + 1 if _, err := store.SetBillingPreferences(context.Background(), SetBillingPreferencesInput{ TenantID: "tenant", LowBalanceThresholdMicros: &threshold, }, 5_000_000); err == nil { t.Fatal("expected excessive low balance threshold to fail") } }