refactor: don't use global Config in private func (#1197)
* refactor: cve_client.go * refactor: don't use global Config in private func * remove import alias for config * refactor: dbclient * refactor: resultDir * refactor: resultsDir * refactor * refactor: gost * refactor: db client * refactor: cveDB * refactor: cvedb * refactor: exploitDB * refactor: remove detector/dbclient.go * refactor: writer * refactor: syslog writer * refactor: ips * refactor: ensureResultDir * refactor: proxy * fix(db): call CloseDB * add integration test * feat(report): sort array in json * sort func for json diff * add build-int to makefile * add int-rds-redis to makefile * fix: test case, makefile * fix makefile * show cve count after diff * make diff * diff -c * sort exploits in json for diff * sort metasploit, exploit
This commit is contained in:
@@ -1281,3 +1281,57 @@ func Test_lessThan(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_ovalResult_Sort(t *testing.T) {
|
||||
type fields struct {
|
||||
entries []defPacks
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want fields
|
||||
}{
|
||||
{
|
||||
name: "already sorted",
|
||||
fields: fields{
|
||||
entries: []defPacks{
|
||||
{def: ovalmodels.Definition{DefinitionID: "0"}},
|
||||
{def: ovalmodels.Definition{DefinitionID: "1"}},
|
||||
},
|
||||
},
|
||||
want: fields{
|
||||
entries: []defPacks{
|
||||
{def: ovalmodels.Definition{DefinitionID: "0"}},
|
||||
{def: ovalmodels.Definition{DefinitionID: "1"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "sort",
|
||||
fields: fields{
|
||||
entries: []defPacks{
|
||||
{def: ovalmodels.Definition{DefinitionID: "1"}},
|
||||
{def: ovalmodels.Definition{DefinitionID: "0"}},
|
||||
},
|
||||
},
|
||||
want: fields{
|
||||
entries: []defPacks{
|
||||
{def: ovalmodels.Definition{DefinitionID: "0"}},
|
||||
{def: ovalmodels.Definition{DefinitionID: "1"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
o := &ovalResult{
|
||||
entries: tt.fields.entries,
|
||||
}
|
||||
o.Sort()
|
||||
|
||||
if !reflect.DeepEqual(o.entries, tt.want.entries) {
|
||||
t.Errorf("act %#v, want %#v", o.entries, tt.want.entries)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user