aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dbstore/dbstore_test.go35
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)
}
}