feat(scanner/redhat): each package has modularitylabel (#1381)
This commit is contained in:
@@ -223,6 +223,26 @@ func TestParseInstalledPackagesLine(t *testing.T) {
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"community-mysql 0 8.0.26 1.module_f35+12627+b26747dd x86_64 mysql:8.0:3520210817160118:f27b74a8",
|
||||
models.Package{
|
||||
Name: "community-mysql",
|
||||
Version: "8.0.26",
|
||||
Release: "1.module_f35+12627+b26747dd",
|
||||
ModularityLabel: "mysql:8.0:3520210817160118:f27b74a8",
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"dnf-utils 0 4.0.24 1.fc35 noarch (none)",
|
||||
models.Package{
|
||||
Name: "dnf-utils",
|
||||
Version: "4.0.24",
|
||||
Release: "1.fc35",
|
||||
ModularityLabel: "",
|
||||
},
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tt := range packagetests {
|
||||
@@ -242,6 +262,9 @@ func TestParseInstalledPackagesLine(t *testing.T) {
|
||||
if p.Release != tt.pack.Release {
|
||||
t.Errorf("release: expected %s, actual %s", tt.pack.Release, p.Release)
|
||||
}
|
||||
if p.ModularityLabel != tt.pack.ModularityLabel {
|
||||
t.Errorf("modularitylabel: expected %s, actual %s", tt.pack.ModularityLabel, p.ModularityLabel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,47 +548,6 @@ func TestParseNeedsRestarting(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Test_redhatBase_parseDnfModuleList(t *testing.T) {
|
||||
type args struct {
|
||||
stdout string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
wantLabels []string
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Success",
|
||||
args: args{
|
||||
stdout: `Red Hat Enterprise Linux 8 for x86_64 - AppStream from RHUI (RPMs)
|
||||
Name Stream Profiles Summary
|
||||
virt rhel [d][e] common [d] Virtualization module
|
||||
nginx 1.14 [d][e] common [d] [i] nginx webserver
|
||||
|
||||
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled`,
|
||||
},
|
||||
wantLabels: []string{
|
||||
"nginx:1.14",
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
o := &redhatBase{}
|
||||
gotLabels, err := o.parseDnfModuleList(tt.args.stdout)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("redhatBase.parseDnfModuleList() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !reflect.DeepEqual(gotLabels, tt.wantLabels) {
|
||||
t.Errorf("redhatBase.parseDnfModuleList() = %v, want %v", gotLabels, tt.wantLabels)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_redhatBase_parseRpmQfLine(t *testing.T) {
|
||||
type fields struct {
|
||||
base base
|
||||
|
||||
Reference in New Issue
Block a user