package dbstore import ( "github.com/pablotron/cvez/feed" "testing" ) func TestCheckNvdData(t *testing.T) { passTests := []struct { name string dt feed.DataType df feed.DataFormat dv feed.DataVersion } { { "valid", feed.CveType, feed.MitreFormat, feed.V40 }, } for _, test := range(passTests) { t.Run(test.name, func(t *testing.T) { if err := checkNvdData(test.dt, test.df, test.dv); err != nil { t.Error(err) } }) } failTests := []struct { name string dt feed.DataType df feed.DataFormat dv feed.DataVersion } { { "bad type", feed.DataType(255), feed.MitreFormat, feed.V40 }, { "bad format", feed.CveType, feed.DataFormat(255), feed.V40 }, { "bad version", feed.CveType, feed.MitreFormat, feed.DataVersion(255) }, } for _, test := range(failTests) { t.Run(test.name, func(t *testing.T) { if checkNvdData(test.dt, test.df, test.dv) == nil { t.Errorf("got success, exp error") } }) } }