Refactor to use conndata as menustorageservice conn arg

This commit is contained in:
lash
2025-01-04 20:36:18 +00:00
parent f61e65f4fe
commit 450dfa02cc
12 changed files with 98 additions and 125 deletions

View File

@@ -5,32 +5,23 @@ import (
)
func TestParseConnStr(t *testing.T) {
svc := NewMenuStorageService("")
err := svc.SetConn("postgres://foo:bar@localhost:5432/baz")
_, err := ToConnData("postgres://foo:bar@localhost:5432/baz")
if err != nil {
t.Fatal(err)
}
err = svc.SetConn("/foo/bar/baz.gdbm")
_, err = ToConnData("/foo/bar")
if err != nil {
t.Fatal(err)
}
err = svc.SetConn("foo/bar/baz.gdbm")
_, err = ToConnData("/foo/bar/")
if err != nil {
t.Fatal(err)
}
_, err = ToConnData("foo/bar")
if err == nil {
t.Fatalf("expected error")
}
err = svc.SetConn("http://foo/bar")
if err == nil {
t.Fatalf("expected error")
}
err = svc.SetConn("foo/bar/baz.txt")
if err == nil {
t.Fatalf("expected error")
}
err = svc.SetConn("/foo/bar")
if err == nil {
t.Fatalf("expected error")
}
err = svc.SetConn("foo/bar")
_, err = ToConnData("http://foo/bar")
if err == nil {
t.Fatalf("expected error")
}