diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-02-05 11:18:33 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-02-05 11:18:33 -0500 |
commit | c89f404a0176415130089201a176a3ff76a02829 (patch) | |
tree | a8f0232eea81c83901a8957c90b342afb56b8e51 /dbstore/dbstore_test.go | |
parent | 351c3531a932b30ad42d144b344edd23c1693559 (diff) | |
download | cvez-c89f404a0176415130089201a176a3ff76a02829.tar.bz2 cvez-c89f404a0176415130089201a176a3ff76a02829.zip |
dbstore: add CpeSearch() fail tests
Diffstat (limited to 'dbstore/dbstore_test.go')
-rw-r--r-- | dbstore/dbstore_test.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/dbstore/dbstore_test.go b/dbstore/dbstore_test.go index 829d3c3..fe653dc 100644 --- a/dbstore/dbstore_test.go +++ b/dbstore/dbstore_test.go @@ -440,7 +440,8 @@ func TestCpeSearch(t *testing.T) { path := "./testdata/test-search.db" ctx := context.Background() - tests := []struct { + // tests that are expected to pass + passTests := []struct { t CpeSearchType // search type q string // query string exp []string // expected search results (cpe23s) @@ -486,7 +487,7 @@ func TestCpeSearch(t *testing.T) { return } - for _, test := range(tests) { + for _, test := range(passTests) { t.Run(test.t.String(), func(t *testing.T) { rows, err := db.CpeSearch(ctx, test.t, test.q) if err != nil { @@ -506,4 +507,21 @@ func TestCpeSearch(t *testing.T) { } }) } + + // tests that are expected to fail + failTests := []struct { + name string // test name + t CpeSearchType // search type + q string // query string + } { + { "bad-search-type", CpeSearchType(255), "" }, + } + + for _, test := range(failTests) { + t.Run(test.name, func(t *testing.T) { + if got, err := db.CpeSearch(ctx, test.t, test.q); err == nil { + t.Errorf("got \"%v\", exp error", got) + } + }) + } } |