diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-02-05 03:03:43 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-02-05 03:03:43 -0500 |
commit | dd2de2882f707d84be0b7b8f4b47b49ce5b0e2d3 (patch) | |
tree | 098d2ad071037b1400bf00c5df987870470edebf /dbstore | |
parent | 3dd8e3b14cce7d46779b497ea7a08581cf7663fb (diff) | |
download | cvez-dd2de2882f707d84be0b7b8f4b47b49ce5b0e2d3.tar.bz2 cvez-dd2de2882f707d84be0b7b8f4b47b49ce5b0e2d3.zip |
dbstore: add Open failure tests
Diffstat (limited to 'dbstore')
-rw-r--r-- | dbstore/dbstore_test.go | 22 |
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) + } + }) } } |