Set NotFixedYet for Ubuntu Scan
This commit is contained in:
@@ -45,8 +45,15 @@ type defPacks struct {
|
||||
}
|
||||
|
||||
func (e defPacks) toPackStatuses() (ps models.PackageStatuses) {
|
||||
packNotFixedYet := map[string]bool{}
|
||||
for _, p := range e.def.AffectedPacks {
|
||||
packNotFixedYet[p.Name] = p.NotFixedYet
|
||||
}
|
||||
for k := range e.actuallyAffectedPackNames {
|
||||
ps = append(ps, models.PackageStatus{Name: k})
|
||||
ps = append(ps, models.PackageStatus{
|
||||
Name: k,
|
||||
NotFixedYet: packNotFixedYet[k],
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package oval
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/future-architect/vuls/models"
|
||||
ovalmodels "github.com/kotakanbe/goval-dictionary/models"
|
||||
)
|
||||
|
||||
@@ -96,3 +98,50 @@ func TestUpsert(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefpacksToPackStatuses(t *testing.T) {
|
||||
var tests = []struct {
|
||||
in defPacks
|
||||
out models.PackageStatuses
|
||||
}{
|
||||
{
|
||||
in: defPacks{
|
||||
def: ovalmodels.Definition{
|
||||
AffectedPacks: []ovalmodels.Package{
|
||||
{
|
||||
Name: "a",
|
||||
NotFixedYet: true,
|
||||
},
|
||||
{
|
||||
Name: "b",
|
||||
NotFixedYet: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
actuallyAffectedPackNames: map[string]bool{
|
||||
"a": true,
|
||||
"b": false,
|
||||
},
|
||||
},
|
||||
out: models.PackageStatuses{
|
||||
{
|
||||
Name: "a",
|
||||
NotFixedYet: true,
|
||||
},
|
||||
{
|
||||
Name: "b",
|
||||
NotFixedYet: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
actual := tt.in.toPackStatuses()
|
||||
sort.Slice(actual, func(i, j int) bool {
|
||||
return actual[i].Name < actual[j].Name
|
||||
})
|
||||
if !reflect.DeepEqual(actual, tt.out) {
|
||||
t.Errorf("[%d]\nexpected: %v\n actual: %v\n", i, tt.out, actual)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user