You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.3 KiB
50 lines
1.3 KiB
package config
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestInitalize(t *testing.T) {
|
|
os.Setenv("DATABASE_USER", "username") // no default value set for username
|
|
if err := Initialize("", "", map[string]interface{}{}); err != nil {
|
|
t.Errorf("defaults not proper set: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateEnvironment(t *testing.T) {
|
|
if err := validateEnvironment("brokenValue"); err == nil {
|
|
t.Errorf("environment validation failed: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateListenAddress(t *testing.T) {
|
|
if err := validateListenAddress("broken@Value"); err == nil {
|
|
t.Errorf("listenaddress validation failed: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func TestValidatePort(t *testing.T) {
|
|
if err := validatePort("parent", "70000"); err == nil {
|
|
t.Errorf("port validation failed: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateHost(t *testing.T) {
|
|
if err := validateHost("parent", "broken@Value"); err == nil {
|
|
t.Errorf("host validation failed: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateDatabaseDialect(t *testing.T) {
|
|
if err := validateDatabaseDialect("brokenValue"); err == nil {
|
|
t.Errorf("database dialect validation failed: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func TestValidateUsername(t *testing.T) {
|
|
os.Setenv("DATABASE_USER", "")
|
|
if err := Initialize("", "", map[string]interface{}{}); err == nil {
|
|
t.Errorf("username validation failed: %v\n", err)
|
|
}
|
|
}
|