aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbstore/dbstore_test.go22
1 files changed, 17 insertions, 5 deletions
diff --git a/dbstore/dbstore_test.go b/dbstore/dbstore_test.go
index f957146..a64b149 100644
--- a/dbstore/dbstore_test.go
+++ b/dbstore/dbstore_test.go
@@ -208,12 +208,24 @@ func seedTestDb(ctx context.Context, db DbStore) error {
}
func TestOpen(t *testing.T) {
- path := "./testdata/test-new.db"
- ctx := context.Background()
+ tests := []struct {
+ name string
+ path string
+ exp bool
+ } {
+ { "pass", "./testdata/test-new.db", true },
+ { "fail", "/dev/null/does/not/exist", false },
+ }
- if _, err := createTestDb(ctx, path); err != nil {
- t.Error(err)
- return
+ for _, test := range(tests) {
+ t.Run(test.name, func(t *testing.T) {
+ got, err := createTestDb(context.Background(), test.path)
+ if test.exp && err != nil {
+ t.Error(err)
+ } else if !test.exp && err == nil {
+ t.Errorf("got %v, exp error", got)
+ }
+ })
}
}