@@ -0,0 +1,25 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDatabaseURLPreservesCredentials(t *testing.T) {
|
||||
c := Config{PGHost: "192.168.100.127", PGPort: "5432", PGUser: "user@name", PGPassword: "p@ss:/?#&", PGSSLMode: "require"}
|
||||
u, err := url.Parse(c.DatabaseURL("veyra"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
password, _ := u.User.Password()
|
||||
if password != c.PGPassword || u.User.Username() != c.PGUser || u.Path != "/veyra" || u.Query().Get("sslmode") != "require" {
|
||||
t.Fatal("connection URL changed configuration values")
|
||||
}
|
||||
}
|
||||
|
||||
func TestRejectInvalidRedisDB(t *testing.T) {
|
||||
t.Setenv("REDIS_DB", "-1")
|
||||
if _, err := Load(); err == nil {
|
||||
t.Fatal("negative database must be rejected")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user