From 43be1706be867bc81bb8ac0b77961d63196669af Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 18 Mar 2022 00:38:22 -0400 Subject: dbstore/dbstore_test.go: add TestCisaSearch() --- dbstore/dbstore_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'dbstore/dbstore_test.go') diff --git a/dbstore/dbstore_test.go b/dbstore/dbstore_test.go index 524fecb..1f98150 100644 --- a/dbstore/dbstore_test.go +++ b/dbstore/dbstore_test.go @@ -1461,3 +1461,34 @@ func TestAddCisaCatalogs(t *testing.T) { // TODO: TestCisaSearch() // test db: dbstore/testdata/mock-testcisasearch.db // test cases: "wordpad" (1 result), "microsoft excel" (4 results) +func TestCisaSearch(t *testing.T) { + ctx := context.Background() + + tests := []struct { + val string + exp []CisaSearchRow + } {{ + val: "wordpad", + exp: []CisaSearchRow { + CisaSearchRow { + }, + }, + }} + + // connect to test db + db, err := Open("testdata/mock-cisasearch.db") + if err != nil { + t.Error(err) + return + } + + for _, test := range(tests) { + t.Run(test.val, func(t *testing.T) { + if got, err := db.CisaSearch(ctx, test.val); err != nil { + t.Error(err) + } else if !reflect.DeepEqual(got, test.exp) { + t.Errorf("got %v, exp %v", got, test.exp ) + } + }) + } +} -- cgit v1.2.3