From ee154b172cb9eb49d89294abee9e16f1eb21d8a8 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 20 Feb 2022 10:45:38 -0500 Subject: dbstore/dbstore_test.go: replace TestAddCveFeed() with TestAddCveFeeds() --- dbstore/dbstore_test.go | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'dbstore') diff --git a/dbstore/dbstore_test.go b/dbstore/dbstore_test.go index e6e901e..5ec2103 100644 --- a/dbstore/dbstore_test.go +++ b/dbstore/dbstore_test.go @@ -970,7 +970,7 @@ func TestCpeMatchSearch(t *testing.T) { } } -func TestAddCveFeed(t *testing.T) { +func TestAddCveFeeds(t *testing.T) { ctx := context.Background() tests := []string { @@ -986,23 +986,24 @@ func TestAddCveFeed(t *testing.T) { return } - // run tests - for _, test := range(tests) { - t.Run(test, func(t *testing.T) { - // add feed - feed, err := getFeed(fmt.Sprintf("testdata/%s.json.gz", test)) - if err != nil { - t.Error(err) - return - } + // load feeds + feeds := make([]nvd_feed.Feed, len(tests)) + for i, test := range(tests) { + // get feed path + path := fmt.Sprintf("testdata/%s.json.gz", test) - // add feed - _, err = db.AddCveFeed(ctx, feed) - if err != nil { - t.Error(err) - return - } - }) + // get feed + if feed, err := getFeed(path); err != nil { + t.Error(err) + return + } else { + feeds[i] = feed + } + } + + // add feed + if _, err = db.AddCveFeeds(ctx, feeds); err != nil { + t.Error(err) } } -- cgit v1.2.3