1
0
forked from baron/baron-sso
Files
baron-sso/backend/internal/service/dry_run_service_test.go
2026-04-01 20:32:09 +09:00

44 lines
886 B
Go

package service
import (
"os"
"testing"
)
func TestIsProductionEnv_StageIsProductionLike(t *testing.T) {
t.Setenv("APP_ENV", "stage")
t.Setenv("GO_ENV", "")
if !IsProductionEnv() {
t.Fatalf("expected stage to be treated as production-like")
}
}
func TestIsDryRunAllowed_DisabledInStage(t *testing.T) {
t.Setenv("APP_ENV", "stage")
t.Setenv("GO_ENV", "")
if IsDryRunAllowed() {
t.Fatalf("expected dry-run to be disabled in stage")
}
}
func TestIsProductionEnv_FallsBackToGoEnv(t *testing.T) {
originalAppEnv, hadAppEnv := os.LookupEnv("APP_ENV")
if hadAppEnv {
t.Cleanup(func() {
_ = os.Setenv("APP_ENV", originalAppEnv)
})
} else {
t.Cleanup(func() {
_ = os.Unsetenv("APP_ENV")
})
}
_ = os.Unsetenv("APP_ENV")
t.Setenv("GO_ENV", "production")
if !IsProductionEnv() {
t.Fatalf("expected GO_ENV=production fallback to be production-like")
}
}