feat(env): Added production and development environment
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m44s
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m44s
This commit is contained in:
@@ -28,6 +28,9 @@ func TestDefaults(t *testing.T) {
|
||||
if cfg.AdminUsername != "admin" {
|
||||
t.Fatalf("unexpected admin username: %s", cfg.AdminUsername)
|
||||
}
|
||||
if cfg.Environment != AppEnvironmentDevelopment {
|
||||
t.Fatalf("unexpected default environment: %s", cfg.Environment)
|
||||
}
|
||||
if cfg.AdminPassword != "" {
|
||||
t.Fatal("expected default admin password to be empty")
|
||||
}
|
||||
@@ -43,6 +46,7 @@ func TestEnvironmentOverrides(t *testing.T) {
|
||||
t.Setenv("WARPBOX_ADMIN_USERNAME", "root")
|
||||
t.Setenv("WARPBOX_ONE_TIME_DOWNLOAD_RETRY_ON_FAILURE", "true")
|
||||
t.Setenv("WARPBOX_SECURITY_ENABLED", "false")
|
||||
t.Setenv("WARPBOX_ENV", "production")
|
||||
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
@@ -73,6 +77,9 @@ func TestEnvironmentOverrides(t *testing.T) {
|
||||
if cfg.Source(SettingAPIEnabled) != SourceEnv {
|
||||
t.Fatalf("expected API setting source to be env, got %s", cfg.Source(SettingAPIEnabled))
|
||||
}
|
||||
if cfg.Environment != AppEnvironmentProduction {
|
||||
t.Fatalf("expected environment override to be production, got %s", cfg.Environment)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMegabyteSizeEnvironmentOverrides(t *testing.T) {
|
||||
@@ -120,6 +127,12 @@ func TestInvalidEnvironmentValues(t *testing.T) {
|
||||
if _, err := Load(); err == nil {
|
||||
t.Fatal("expected invalid boolean to fail")
|
||||
}
|
||||
|
||||
clearConfigEnv(t)
|
||||
t.Setenv("WARPBOX_ENV", "staging")
|
||||
if _, err := Load(); err == nil {
|
||||
t.Fatal("expected invalid environment mode to fail")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSettingsOverridePrecedence(t *testing.T) {
|
||||
@@ -170,6 +183,7 @@ func clearConfigEnv(t *testing.T) {
|
||||
"WARPBOX_ADMIN_PASSWORD",
|
||||
"WARPBOX_ADMIN_USERNAME",
|
||||
"WARPBOX_ADMIN_EMAIL",
|
||||
"WARPBOX_ENV",
|
||||
"WARPBOX_ADMIN_ENABLED",
|
||||
"WARPBOX_ALLOW_ADMIN_SETTINGS_OVERRIDE",
|
||||
"WARPBOX_ADMIN_COOKIE_SECURE",
|
||||
|
||||
Reference in New Issue
Block a user