Skip to content
Snippets Groups Projects
Commit adca4cec authored by Kevin Lyda's avatar Kevin Lyda :speech_balloon: Committed by Niall Sheridan
Browse files

Db test config (#43)

* Allow tests to specify mysql connection info.

User can set MYSQL_TEST_USER, MYSQL_TEST_PASS and MYSQL_TEST_HOST
environment variables for test environments that need that.

* Changes from testing.

Need to set both time fields as '0000-00-00' depends on a feature
deprecated in MySQL 5.7.4.

Go lint wanted snake case for my sql_config var. sqlConfig it is.

* Go go idioms.

Based on feedback from Niall, a cleaner way to do this in Go.
parent 94ae8fd8
Branches
Tags
No related merge requests found
......@@ -45,6 +45,7 @@ func testStore(t *testing.T, db CertStorer) {
r := &CertRecord{
KeyID: "a",
CreatedAt: time.Now().UTC(),
Expires: time.Now().UTC().Add(1 * time.Minute),
}
if err := db.SetRecord(r); err != nil {
......@@ -92,7 +93,17 @@ func TestMySQLStore(t *testing.T) {
t.Skip("No MYSQL_TEST environment variable")
}
u, _ := user.Current()
db, err := NewSQLStore(map[string]string{"type": "mysql", "username": u.Username})
sqlConfig := map[string]string{
"type": "mysql",
"password": os.Getenv("MYSQL_TEST_PASS"),
"address": os.Getenv("MYSQL_TEST_HOST"),
}
if testUser, ok := os.LookupEnv("MYSQL_TEST_USER"); ok {
sqlConfig["username"] = testUser
} else {
sqlConfig["username"] = u.Username
}
db, err := NewSQLStore(sqlConfig)
if err != nil {
t.Error(err)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment