fleet/server/fleet/software_test.go
Juan Fernandez 4c2ddba2e4
Clean out-of-date NVD results. (#10514)
Keep the vulnerabilities detected via NVD and stored in the DB in sync. with the results from the NVD vulnerability process.
2023-04-03 13:45:18 -04:00

56 lines
928 B
Go

package fleet
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestSoftwareIterQueryOptionsIsValid(t *testing.T) {
testCases := []struct {
excluded []string
included []string
isNotValid bool
}{
{
excluded: nil,
included: nil,
},
{
excluded: []string{"a", "b"},
included: nil,
},
{
excluded: nil,
included: []string{"a", "b"},
},
{
excluded: []string{"a", "b"},
included: []string{"a"},
isNotValid: true,
},
{
excluded: []string{"a"},
included: []string{"a", "b"},
isNotValid: true,
},
{
excluded: []string{"c"},
included: []string{"a", "b"},
isNotValid: true,
},
}
for _, tC := range testCases {
sut := SoftwareIterQueryOptions{
ExcludedSources: tC.excluded,
IncludedSources: tC.included,
}
if tC.isNotValid {
require.False(t, sut.IsValid())
} else {
require.True(t, sut.IsValid())
}
}
}