2018-07-30 09:33:49 +02:00
|
|
|
package sqlstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestConfigDSN(t *testing.T) {
|
|
|
|
c := Config{
|
|
|
|
Driver: "postgres",
|
2018-11-02 11:50:43 +01:00
|
|
|
user: "john",
|
|
|
|
password: "foo",
|
2018-07-30 09:33:49 +02:00
|
|
|
}
|
2018-11-02 11:50:43 +01:00
|
|
|
e := fmt.Sprintf("user=%s password=%s", c.user, c.password)
|
2018-07-30 09:33:49 +02:00
|
|
|
if v := c.DSN(); v != e {
|
|
|
|
t.Errorf("Invalid DSN. Expected %s, got %s", e, v)
|
|
|
|
}
|
|
|
|
|
|
|
|
c = Config{
|
|
|
|
Driver: "postgres",
|
2018-11-02 11:50:43 +01:00
|
|
|
user: "john",
|
|
|
|
password: "foo",
|
|
|
|
sslmode: "disable",
|
2018-07-30 09:33:49 +02:00
|
|
|
}
|
2018-11-02 11:50:43 +01:00
|
|
|
e = fmt.Sprintf("user=%s password=%s sslmode=%s", c.user, c.password, c.sslmode)
|
2018-07-30 09:33:49 +02:00
|
|
|
if v := c.DSN(); v != e {
|
|
|
|
t.Errorf("Invalid DSN. Expected %s, got %s", e, v)
|
|
|
|
}
|
|
|
|
}
|