aboutsummaryrefslogtreecommitdiff
path: root/dbstore
diff options
context:
space:
mode:
Diffstat (limited to 'dbstore')
-rw-r--r--dbstore/dbstore_test.go22
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)
+ }
+ })
+ }
}