forked from adjust/goenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostgres_test.go
35 lines (28 loc) · 1000 Bytes
/
postgres_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package goenv
import (
"testing"
)
func TestGetPostgres(t *testing.T) {
goenv := NewGoenv("./test_config.yml", "postgres", "nil")
if goenv.GetPostgres() != "user=ter dbname=41 sslmode=disable host=hor port=4711" {
t.Error("postgres != user=ter dbname=41 sslmode=disable host=hor port=4711")
}
}
func TestGetPostgresNotFound(t *testing.T) {
defer func() { recover() }()
goenv := NewGoenv("./test_config.yml", "nonexistent", "nil")
goenv.GetPostgres()
t.Error("GetPostgres didn't panic")
}
func TestGetNamedPostgres(t *testing.T) {
goenv := NewGoenv("./test_config.yml", "postgres", "nil")
if goenv.GetNamedPostgres("custom") != "user=orr dbname=11 sslmode=disable host=obk port=5432" {
t.Error("custom != user=orr dbname=11 sslmode=disable host=obk port=5432")
}
}
func TestGetNamedPostgresNotFound(t *testing.T) {
defer func() { recover() }()
goenv := NewGoenv("./test_config.yml", "postgres", "nil")
goenv.GetNamedPostgres("non")
t.Error("GetNamedPostgres didn't panic")
}