From 032ee1f3be9ccdf4cb5cfeb682e6b92eb6626371 Mon Sep 17 00:00:00 2001 From: Andre Marianiello Date: Wed, 27 Mar 2024 10:02:18 -0400 Subject: [PATCH] internal/blueprint: Go fmt customizations test --- internal/blueprint/customizations_test.go | 34 ++++++----------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/internal/blueprint/customizations_test.go b/internal/blueprint/customizations_test.go index 05d744a2fe0..c6684da512b 100644 --- a/internal/blueprint/customizations_test.go +++ b/internal/blueprint/customizations_test.go @@ -20,7 +20,7 @@ func TestCheckAllowed(t *testing.T) { GID := 321 expectedUsers := []UserCustomization{ - UserCustomization{ + { Name: "John", Description: &Desc, Password: &Pass, @@ -33,7 +33,7 @@ func TestCheckAllowed(t *testing.T) { }, } - var expectedHostname = "Hostname" + expectedHostname := "Hostname" x := Customizations{Hostname: &expectedHostname, User: expectedUsers} @@ -50,8 +50,7 @@ func TestCheckAllowed(t *testing.T) { } func TestGetHostname(t *testing.T) { - - var expectedHostname = "Hostname" + expectedHostname := "Hostname" TestCustomizations := Customizations{ Hostname: &expectedHostname, @@ -59,11 +58,9 @@ func TestGetHostname(t *testing.T) { retHostname := TestCustomizations.GetHostname() assert.Equal(t, &expectedHostname, retHostname) - } func TestGetKernel(t *testing.T) { - expectedKernel := KernelCustomization{ Append: "--test", Name: "kernel", @@ -79,9 +76,8 @@ func TestGetKernel(t *testing.T) { } func TestSSHKey(t *testing.T) { - expectedSSHKeys := []SSHKeyCustomization{ - SSHKeyCustomization{ + { User: "test-user", Key: "test-key", }, @@ -95,11 +91,9 @@ func TestSSHKey(t *testing.T) { assert.Equal(t, expectedSSHKeys[0].User, retUser) assert.Equal(t, expectedSSHKeys[0].Key, retKey) - } func TestGetUsers(t *testing.T) { - Desc := "Test descritpion" Pass := "testpass" Key := "testkey" @@ -113,7 +107,7 @@ func TestGetUsers(t *testing.T) { ExpireDate := 12345 expectedUsers := []UserCustomization{ - UserCustomization{ + { Name: "John", Description: &Desc, Password: &Pass, @@ -137,10 +131,9 @@ func TestGetUsers(t *testing.T) { } func TestGetGroups(t *testing.T) { - GID := 1234 expectedGroups := []GroupCustomization{ - GroupCustomization{ + { Name: "TestGroup", GID: &GID, }, @@ -156,7 +149,6 @@ func TestGetGroups(t *testing.T) { } func TestGetTimezoneSettings(t *testing.T) { - expectedTimezone := "testZONE" expectedNTPServers := []string{ "server", @@ -175,11 +167,9 @@ func TestGetTimezoneSettings(t *testing.T) { assert.Equal(t, expectedTimezone, *retTimezone) assert.Equal(t, expectedNTPServers, retNTPServers) - } func TestGetPrimaryLocale(t *testing.T) { - expectedLanguages := []string{ "enUS", } @@ -201,7 +191,6 @@ func TestGetPrimaryLocale(t *testing.T) { } func TestGetFirewall(t *testing.T) { - expectedPorts := []string{"22", "9090"} expectedServices := FirewallServicesCustomization{ @@ -226,7 +215,6 @@ func TestGetFirewall(t *testing.T) { } func TestGetServices(t *testing.T) { - expectedServices := ServicesCustomization{ Enabled: []string{"cockpit", "osbuild-composer"}, Disabled: []string{"sshd", "ftp"}, @@ -252,12 +240,10 @@ func TestError(t *testing.T) { retError := expectedError.Error() assert.Equal(t, expectedError.Message, retError) - } // This tests calling all the functions on a Blueprint with no Customizations func TestNoCustomizationsInBlueprint(t *testing.T) { - TestBP := Blueprint{} assert.Nil(t, TestBP.Customizations.GetHostname()) @@ -278,8 +264,7 @@ func TestNoCustomizationsInBlueprint(t *testing.T) { // This tests additional scenarios where GetPrimaryLocale() returns nil values func TestNilGetPrimaryLocale(t *testing.T) { - - //Case empty Customization + // Case empty Customization TestCustomizationsEmpty := Customizations{} retLanguage, retKeyboard := TestCustomizationsEmpty.GetPrimaryLocale() @@ -287,7 +272,7 @@ func TestNilGetPrimaryLocale(t *testing.T) { assert.Nil(t, retLanguage) assert.Nil(t, retKeyboard) - //Case empty Languages + // Case empty Languages expectedKeyboard := "en" expectedLocaleCustomization := LocaleCustomization{ Keyboard: &expectedKeyboard, @@ -301,12 +286,10 @@ func TestNilGetPrimaryLocale(t *testing.T) { assert.Nil(t, retLanguage) assert.Equal(t, expectedKeyboard, *retKeyboard) - } // This tests additional scenario where GetTimezoneSEtting() returns nil values func TestNilGetTimezoneSettings(t *testing.T) { - TestCustomizationsEmpty := Customizations{} retTimezone, retNTPServers := TestCustomizationsEmpty.GetTimezoneSettings() @@ -316,7 +299,6 @@ func TestNilGetTimezoneSettings(t *testing.T) { } func TestGetOpenSCAPConfig(t *testing.T) { - expectedOscap := OpenSCAPCustomization{ DataStream: "test-data-stream.xml", ProfileID: "test_profile",