Initial commit: runnable Ask a Plumber First server.

This commit is contained in:
2026-08-21 23:30:15 -07:00
parent 7bc79af954
commit d167b9216a
38 changed files with 4174 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
package store
import "testing"
func TestRebindPostgresPlaceholders(t *testing.T) {
got := rebind(`SELECT a FROM t WHERE x = ? AND y = ?`)
want := `SELECT a FROM t WHERE x = $1 AND y = $2`
if got != want {
t.Fatalf("got %q", got)
}
}
func TestNormalizeUsername(t *testing.T) {
if got := NormalizeUsername(" Alice_1 "); got != "alice_1" {
t.Fatalf("got %q", got)
}
}
func TestPostgresDSNDefaultsSSLMode(t *testing.T) {
in := "postgresql://user:pass@db.example.com:5432/postgres"
out, err := postgresDSN(in)
if err != nil {
t.Fatal(err)
}
if !containsAny(out, "sslmode=verify-full") {
t.Fatalf("missing default sslmode: %s", out)
}
}
func containsAny(s string, parts ...string) bool {
for _, p := range parts {
if len(p) > 0 && (len(s) >= len(p)) {
for i := 0; i+len(p) <= len(s); i++ {
if s[i:i+len(p)] == p {
return true
}
}
}
}
return false
}