diff options
author | Paul Duncan <pabs@pablotron.org> | 2022-02-20 10:45:38 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2022-02-20 10:45:38 -0500 |
commit | ee154b172cb9eb49d89294abee9e16f1eb21d8a8 (patch) | |
tree | 6379f715df2d03e5d1b451c09b0d113125891bd0 | |
parent | 4cbd88b2387f12b9052033fc05445e2c6b54ab96 (diff) | |
download | cvez-ee154b172cb9eb49d89294abee9e16f1eb21d8a8.tar.bz2 cvez-ee154b172cb9eb49d89294abee9e16f1eb21d8a8.zip |
dbstore/dbstore_test.go: replace TestAddCveFeed() with TestAddCveFeeds()
-rw-r--r-- | dbstore/dbstore_test.go | 35 |
1 files changed, 18 insertions, 17 deletions
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) } } |