Skip to content

Commit

Permalink
RHINENG-6806: improve test for analyzePackage
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMraka committed Jan 8, 2024
1 parent 2875ce7 commit 405aa35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions evaluator/evaluate_packages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,17 @@ func TestAnalyzePackages(t *testing.T) {
vmaasData := vmaas.UpdatesV3Response{UpdateList: &map[string]*vmaas.UpdatesV3ResponseUpdateList{
"kernel-0:5.6.13-200.fc31.x86_64": {AvailableUpdates: &[]vmaas.UpdatesV3ResponseAvailableUpdates{}},
"firefox-0:12.0.1-1.fc31.x86_64": {AvailableUpdates: &[]vmaas.UpdatesV3ResponseAvailableUpdates{{
Package: utils.PtrString("firefox-0:77.0.1-1.fc31.x86_64"),
EVRA: utils.PtrString("0:77.0.1-1.fc31.x86_64"),
Package: utils.PtrString("firefox-0:77.0.1-1.fc31.x86_64"),
PackageName: utils.PtrString("firefox"),
EVRA: utils.PtrString("0:77.0.1-1.fc31.x86_64"),
}}},
// this custom-package will NOT be ignored
"custom-package-0:1.2.3-1.fc33.x86_64": {AvailableUpdates: &[]vmaas.UpdatesV3ResponseAvailableUpdates{{}}}}}
"custom-package-0:1.2.3-1.fc33.x86_64": {AvailableUpdates: &[]vmaas.UpdatesV3ResponseAvailableUpdates{
{
Package: utils.PtrString("custom-package-0:2.2.3-1.fc33.x86_64"),
PackageName: utils.PtrString("custom-package"),
EVRA: utils.PtrString("0:2.2.3-1.fc33.x86_64"),
}}}}}

installed, updatable, err := analyzePackages(database.Db, &system, &vmaasData)
assert.Nil(t, err)
Expand Down
2 changes: 1 addition & 1 deletion evaluator/evaluate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestEvaluateYum(t *testing.T) {
expectedAdvisoryIDs := []int64{1, 2, 100, 14} // advisories expected to be paired to the system after evaluation
oldSystemAdvisoryIDs := []int64{1, 2} // old advisories paired with the system
expectedPackageIDs := []int64{
1, 2, 107} // kernel-5.6.13-200.fc31.x86_64, firefox-76.0.1-1.fc31.x86_64, suricata-6.0.3-2.fc35.i686
1, 2, 108} // kernel-5.6.13-200.fc31.x86_64, firefox-76.0.1-1.fc31.x86_64, suricata-6.0.3-2.fc35.i686

database.DeleteSystemAdvisories(t, sysID, expectedAdvisoryIDs)
database.DeleteAdvisoryAccountData(t, rhAccountID, expectedAdvisoryIDs)
Expand Down
2 changes: 1 addition & 1 deletion evaluator/package_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestGetPackageCache(t *testing.T) {
assert.Equal(t, "11", string(val.DescriptionHash))
val, ok = pc.GetLatestByName("kernel")
assert.True(t, ok)
assert.Equal(t, int64(106), val.ID)
assert.Equal(t, int64(107), val.ID)
assert.Equal(t, "kernel", val.Name)
assert.Equal(t, "5.10.13-200.fc31.x86_64", val.Evra)
assert.Equal(t, int64(101), val.NameID)
Expand Down

0 comments on commit 405aa35

Please sign in to comment.