From a083e78bbecb8625369df84cd55558e47f9cb364 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Thu, 25 Apr 2024 00:27:12 +0200 Subject: [PATCH] manifest: check len(SudoNopasswd) in test instead of true/false Check the input instead of passing true/false for every test. --- pkg/manifest/anaconda_installer_iso_tree_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/manifest/anaconda_installer_iso_tree_test.go b/pkg/manifest/anaconda_installer_iso_tree_test.go index 56c871871d..057ccd497f 100644 --- a/pkg/manifest/anaconda_installer_iso_tree_test.go +++ b/pkg/manifest/anaconda_installer_iso_tree_test.go @@ -330,7 +330,7 @@ func TestAnacondaISOTreeSerializeWithOS(t *testing.T) { pipeline.serializeEnd() assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux", "org.osbuild.kickstart"), variantStages)) - assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, false, "")) + assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, len(pipeline.Kickstart.SudoNopasswd) > 0, "")) }) t.Run("unattended+sudo", func(t *testing.T) { @@ -347,7 +347,7 @@ func TestAnacondaISOTreeSerializeWithOS(t *testing.T) { pipeline.serializeEnd() assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux", "org.osbuild.kickstart"), variantStages)) - assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, true, "")) + assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, len(pipeline.Kickstart.SudoNopasswd) > 0, "")) }) t.Run("user-kickstart-without-sudo-bits", func(t *testing.T) { @@ -367,7 +367,7 @@ func TestAnacondaISOTreeSerializeWithOS(t *testing.T) { pipeline.serializeEnd() assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux", "org.osbuild.kickstart"), variantStages)) - assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, false, userks)) + assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, len(pipeline.Kickstart.SudoNopasswd) > 0, userks)) }) t.Run("user-kickstart-with-sudo-bits", func(t *testing.T) { @@ -388,7 +388,7 @@ func TestAnacondaISOTreeSerializeWithOS(t *testing.T) { pipeline.serializeEnd() assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux", "org.osbuild.kickstart"), variantStages)) - assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, true, userks)) + assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, len(pipeline.Kickstart.SudoNopasswd) > 0, userks)) }) } @@ -441,7 +441,7 @@ func TestAnacondaISOTreeSerializeWithOSTree(t *testing.T) { sp := pipeline.serialize() pipeline.serializeEnd() assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux"), variantStages)) - assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, false, "")) + assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, len(pipeline.Kickstart.SudoNopasswd) > 0, "")) }) t.Run("unattended+sudo", func(t *testing.T) { @@ -456,7 +456,7 @@ func TestAnacondaISOTreeSerializeWithOSTree(t *testing.T) { sp := pipeline.serialize() pipeline.serializeEnd() assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux"), variantStages)) - assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, true, "")) + assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, len(pipeline.Kickstart.SudoNopasswd) > 0, "")) }) t.Run("user-kickstart-without-sudo-bits", func(t *testing.T) { @@ -474,7 +474,7 @@ func TestAnacondaISOTreeSerializeWithOSTree(t *testing.T) { sp := pipeline.serialize() pipeline.serializeEnd() assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux"), variantStages)) - assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, false, userks)) + assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, len(pipeline.Kickstart.SudoNopasswd) > 0, userks)) }) t.Run("user-kickstart-with-sudo-bits", func(t *testing.T) { @@ -493,7 +493,7 @@ func TestAnacondaISOTreeSerializeWithOSTree(t *testing.T) { sp := pipeline.serialize() pipeline.serializeEnd() assert.NoError(t, checkISOTreeStages(sp.Stages, append(payloadStages, "org.osbuild.isolinux"), variantStages)) - assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, true, userks)) + assert.NoError(t, checkKickstartUnattendedOptions(sp.Stages, len(pipeline.Kickstart.SudoNopasswd) > 0, userks)) }) }