27 lines
514 B
Go
27 lines
514 B
Go
package data
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"kra/internal/config"
|
|
)
|
|
|
|
func TestMySQLDatabaseDSNIncludesNetworkTimeouts(t *testing.T) {
|
|
dsn, err := databaseDSN(&config.Database{
|
|
Driver: "mysql",
|
|
User: "root",
|
|
Password: "secret",
|
|
Host: "mysql",
|
|
Name: "kra",
|
|
}, "")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, option := range []string{"timeout=5s", "readTimeout=5s", "writeTimeout=5s"} {
|
|
if !strings.Contains(dsn, option) {
|
|
t.Fatalf("DSN %q does not contain %q", dsn, option)
|
|
}
|
|
}
|
|
}
|