From 405aa3598abde5524412fb493f1801270e77293f Mon Sep 17 00:00:00 2001 From: Michael Mraka Date: Fri, 5 Jan 2024 14:36:29 +0100 Subject: [PATCH] RHINENG-6806: improve test for analyzePackage --- evaluator/evaluate_packages_test.go | 12 +++++++++--- evaluator/evaluate_test.go | 2 +- evaluator/package_cache_test.go | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/evaluator/evaluate_packages_test.go b/evaluator/evaluate_packages_test.go index 46967360d..78b3ea914 100644 --- a/evaluator/evaluate_packages_test.go +++ b/evaluator/evaluate_packages_test.go @@ -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) diff --git a/evaluator/evaluate_test.go b/evaluator/evaluate_test.go index 203bdcf8d..cecb44caf 100644 --- a/evaluator/evaluate_test.go +++ b/evaluator/evaluate_test.go @@ -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) diff --git a/evaluator/package_cache_test.go b/evaluator/package_cache_test.go index dc56b0bad..a6103cea4 100644 --- a/evaluator/package_cache_test.go +++ b/evaluator/package_cache_test.go @@ -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)