fix: stabilize development config and account settings
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestWithSanitizedPQEnvironment(t *testing.T) {
|
||||
t.Setenv("PGSERVICE", "local-service")
|
||||
t.Setenv("PGSERVICEFILE", "/tmp/pg_service.conf")
|
||||
t.Setenv("PGREALM", "local-realm")
|
||||
|
||||
err := withSanitizedPQEnvironment(func() error {
|
||||
for _, key := range []string{"PGSERVICE", "PGSERVICEFILE", "PGREALM"} {
|
||||
_, exists := os.LookupEnv(key)
|
||||
require.False(t, exists, "%s should be unset during migration", key)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "local-service", os.Getenv("PGSERVICE"))
|
||||
require.Equal(t, "/tmp/pg_service.conf", os.Getenv("PGSERVICEFILE"))
|
||||
require.Equal(t, "local-realm", os.Getenv("PGREALM"))
|
||||
}
|
||||
|
||||
func TestSanitizePostgresEnvironment(t *testing.T) {
|
||||
t.Setenv("PGSERVICE", "local-service")
|
||||
t.Setenv("PGSERVICEFILE", "/tmp/pg_service.conf")
|
||||
t.Setenv("PGREALM", "local-realm")
|
||||
|
||||
SanitizePostgresEnvironment()
|
||||
|
||||
for _, key := range unsupportedPQEnvironmentKeys {
|
||||
_, exists := os.LookupEnv(key)
|
||||
require.False(t, exists, "%s should be removed at application startup", key)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user