Conflicts resolved (preserving fork customizations): - config.go: keep NodeTLSProxy + add upstream OpenAIHTTP2 - gateway_service.go: NewGatewayService now takes both rpmTokenBucketSvc (local) and userPlatformQuotaRepo (upstream) - wire_gen.go: wire both new args into the call site - http_upstream.go: drop redundant settings re-assignment; keep proxy URL log redaction - http_upstream_test.go: adopt upstream's explicit-0-disables semantics; keep 600s default constant in nil-cfg fallback test - user_handler_test.go / gateway_record_usage_test.go: pick up new userPlatformQuotaRepo nil parameter Also updated test stubs (windsurf_google_login_test.go, windsurf_tier_access_service_test.go, gateway_models_test.go) for new SetModelRateLimit variadic signature and the extra NewGatewayService arg. Upstream highlights: OpenAI embeddings gateway, user x platform USD quota, content-moderation risk thresholds, OAuth 401 credentials no-overwrite fix, HTTP/2 OpenAI upstream config, pool retry status code configurability, long-context cache pricing multipliers.
88 lines
2.3 KiB
Go
88 lines
2.3 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/Wei-Shaw/sub2api/internal/config"
|
|
"github.com/Wei-Shaw/sub2api/internal/handler"
|
|
"github.com/Wei-Shaw/sub2api/internal/service"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestProvideServiceBuildInfo(t *testing.T) {
|
|
in := handler.BuildInfo{
|
|
Version: "v-test",
|
|
BuildType: "release",
|
|
}
|
|
out := provideServiceBuildInfo(in)
|
|
require.Equal(t, in.Version, out.Version)
|
|
require.Equal(t, in.BuildType, out.BuildType)
|
|
}
|
|
|
|
func TestProvideCleanup_WithMinimalDependencies_NoPanic(t *testing.T) {
|
|
cfg := &config.Config{}
|
|
|
|
oauthSvc := service.NewOAuthService(nil, nil)
|
|
openAIOAuthSvc := service.NewOpenAIOAuthService(nil, nil)
|
|
geminiOAuthSvc := service.NewGeminiOAuthService(nil, nil, nil, nil, cfg)
|
|
antigravityOAuthSvc := service.NewAntigravityOAuthService(nil)
|
|
|
|
tokenRefreshSvc := service.NewTokenRefreshService(
|
|
nil,
|
|
oauthSvc,
|
|
openAIOAuthSvc,
|
|
geminiOAuthSvc,
|
|
antigravityOAuthSvc,
|
|
nil,
|
|
nil,
|
|
cfg,
|
|
nil,
|
|
)
|
|
accountExpirySvc := service.NewAccountExpiryService(nil, time.Second)
|
|
subscriptionExpirySvc := service.NewSubscriptionExpiryService(nil, time.Second)
|
|
pricingSvc := service.NewPricingService(cfg, nil)
|
|
emailQueueSvc := service.NewEmailQueueService(nil, 1)
|
|
billingCacheSvc := service.NewBillingCacheService(nil, nil, nil, nil, nil, nil, cfg, nil)
|
|
idempotencyCleanupSvc := service.NewIdempotencyCleanupService(nil, cfg)
|
|
schedulerSnapshotSvc := service.NewSchedulerSnapshotService(nil, nil, nil, nil, cfg)
|
|
opsSystemLogSinkSvc := service.NewOpsSystemLogSink(nil)
|
|
|
|
cleanup := provideCleanup(
|
|
nil, // entClient
|
|
nil, // redis
|
|
&service.OpsMetricsCollector{},
|
|
&service.OpsAggregationService{},
|
|
&service.OpsAlertEvaluatorService{},
|
|
&service.OpsCleanupService{},
|
|
&service.OpsScheduledReportService{},
|
|
opsSystemLogSinkSvc,
|
|
schedulerSnapshotSvc,
|
|
tokenRefreshSvc,
|
|
accountExpirySvc,
|
|
subscriptionExpirySvc,
|
|
&service.UsageCleanupService{},
|
|
idempotencyCleanupSvc,
|
|
pricingSvc,
|
|
emailQueueSvc,
|
|
billingCacheSvc,
|
|
&service.UsageRecordWorkerPool{},
|
|
&service.SubscriptionService{},
|
|
oauthSvc,
|
|
openAIOAuthSvc,
|
|
geminiOAuthSvc,
|
|
antigravityOAuthSvc,
|
|
nil, // openAIGateway
|
|
nil, // scheduledTestRunner
|
|
nil, // backupSvc
|
|
nil, // paymentOrderExpiry
|
|
nil, // windsurfRefresh
|
|
nil, // channelMonitorRunner
|
|
nil, // windsurfLS
|
|
)
|
|
|
|
require.NotPanics(t, func() {
|
|
cleanup()
|
|
})
|
|
}
|