//go:build integration package bootstrap import ( "context" "os" "strings" "testing" "time" "proxy-pool/internal/config" "proxy-pool/internal/controller/admin" controllerRuntime "proxy-pool/internal/controller/runtime" ) func TestProductionBootstrapOpensBothStoresAndCommitsStartupConfiguration(t *testing.T) { postgresURL := os.Getenv("PROXY_POOL_TEST_POSTGRES_URL") redisURL := os.Getenv("PROXY_POOL_TEST_REDIS_URL") if postgresURL == "" || redisURL == "" { t.Skip("PROXY_POOL_TEST_POSTGRES_URL and PROXY_POOL_TEST_REDIS_URL are required") } source := strings.ReplaceAll(bootstrapTestConfig, "postgres://fixture", postgresURL) source = strings.ReplaceAll(source, "redis://fixture", redisURL) resolver := &memoryResolver{files: map[string][]byte{"controller.yaml": []byte(source)}} factory := &integrationRuntimeFactory{} err := run(context.Background(), Options{ ConfigPath: "controller.yaml", Resolver: resolver, Now: func() time.Time { return time.Date(2026, 7, 30, 13, 0, 0, 0, time.UTC) }, }, &productionInfrastructure{}, factory) if err != nil { t.Fatalf("run() error = %v", err) } if factory.status.ConfigVersion == "" || len(factory.status.Upstreams) != 2 { t.Fatalf("Admin Status = %+v", factory.status) } if factory.status.Upstreams[0].Name != "provider-a" || factory.status.Upstreams[0].Available != 0 || factory.status.Upstreams[1].Name != "provider-b" { t.Fatalf("Admin Status upstreams = %+v", factory.status.Upstreams) } } type integrationRuntimeFactory struct { status admin.Status } func (factory *integrationRuntimeFactory) New( _ *config.Config, dependencies controllerRuntime.Dependencies, _ controllerRuntime.Options, ) (controllerRunner, error) { return integrationRunner{run: func(ctx context.Context) error { if err := dependencies.Readiness.Ready(ctx); err != nil { return err } status, err := dependencies.AdminService.Status(ctx) factory.status = status return err }}, nil } type integrationRunner struct { run func(context.Context) error } func (runner integrationRunner) Run(ctx context.Context) error { return runner.run(ctx) }