WIP SQL test

This commit is contained in:
AJ ONeal 2020-09-16 05:09:48 -06:00
parent e075d319de
commit 7fb9fff11b
2 changed files with 14 additions and 10 deletions

View File

@ -0,0 +1,14 @@
package authstore
import "strings"
var connStr = "postgres://postgres:postgres@localhost/postgres"
func init() {
// TODO url.Parse
if strings.Contains(connStr, "@localhost/") || strings.Contains(connStr, "@localhost:") {
connStr += "?sslmode=disable"
} else {
connStr += "?sslmode=required"
}
}

View File

@ -2,22 +2,12 @@ package authstore
import (
"fmt"
"strings"
"testing"
)
func TestStore(t *testing.T) {
// Note: test output is cached (running twice will not result in two records)
connStr := "postgres://postgres:postgres@localhost/postgres"
if strings.Contains(connStr, "@localhost/") || strings.Contains(connStr, "@localhost:") {
connStr += "?sslmode=disable"
} else {
connStr += "?sslmode=required"
}
// TODO url.Parse
store, err := NewStore(connStr, initSQL)
if nil != err {
t.Fatal("connection error", err)