MCPcopy
hub / github.com/gourouting/singo / TestDatabaseDSNRequiresUserAndName

Function TestDatabaseDSNRequiresUserAndName

conf/conf_test.go:55–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestDatabaseDSNRequiresUserAndName(t *testing.T) {
56 setDBEnv(t, map[string]string{})
57
58 dsn, err := DatabaseDSN()
59 if err == nil {
60 t.Fatal("expected missing config error")
61 }
62 if dsn != "" {
63 t.Fatalf("expected empty DSN, got %q", dsn)
64 }
65
66 msg := err.Error()
67 if !strings.Contains(msg, "DB_USER") || !strings.Contains(msg, "DB_NAME") {
68 t.Fatalf("expected error to mention missing DB_USER and DB_NAME, got %q", msg)
69 }
70}
71
72func TestDatabaseDSNUsesDefaults(t *testing.T) {
73 setDBEnv(t, map[string]string{

Callers

nothing calls this directly

Calls 3

setDBEnvFunction · 0.85
DatabaseDSNFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected