internal/blueprint: Go fmt customizations test

This commit is contained in:
Andre Marianiello 2024-03-27 10:02:18 -04:00 committed by Simon Steinbeiß
parent 0ece609c8b
commit 0ef11c1f07

View file

@ -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",