diff --git a/pkg/build/testdata/minimal-test-definition.yaml b/pkg/build/testdata/minimal-test-definition.yaml deleted file mode 100644 index 3f59a8f8..00000000 --- a/pkg/build/testdata/minimal-test-definition.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: 1.0 -image: - imageType: iso - baseImage: slemicro5.5.iso - outputImageName: eibimage.iso diff --git a/pkg/build/testdata/users-test-definition.yaml b/pkg/build/testdata/users-test-definition.yaml deleted file mode 100644 index 5c06a171..00000000 --- a/pkg/build/testdata/users-test-definition.yaml +++ /dev/null @@ -1,12 +0,0 @@ -operatingSystem: - users: - - username: alpha - password: alpha123 - sshKey: alphakey - - username: beta - password: beta123 - - username: gamma - sshKey: gammakey - - username: root - password: root123 - sshKey: rootkey diff --git a/pkg/build/users_test.go b/pkg/build/users_test.go index 16ecf1f0..0c4097eb 100644 --- a/pkg/build/users_test.go +++ b/pkg/build/users_test.go @@ -13,10 +13,30 @@ import ( func TestConfigureUsers(t *testing.T) { // Setup - configData, err := os.ReadFile("./testdata/users-test-definition.yaml") - require.NoError(t, err) - imageConfig, err := config.Parse(configData) - require.NoError(t, err) + imageConfig := &config.ImageConfig{ + OperatingSystem: config.OperatingSystem{ + Users: []config.OperatingSystemUser{ + { + Username: "alpha", + Password: "alpha123", + SSHKey: "alphakey", + }, + { + Username: "beta", + Password: "beta123", + }, + { + Username: "gamma", + SSHKey: "gammakey", + }, + { + Username: "root", + Password: "root123", + SSHKey: "rootkey", + }, + }, + }, + } context, err := NewContext("", "", true) require.NoError(t, err) @@ -76,11 +96,6 @@ func TestConfigureUsers(t *testing.T) { func TestConfigureUsers_NoUsers(t *testing.T) { // Setup - configData, err := os.ReadFile("./testdata/minimal-test-definition.yaml") - require.NoError(t, err) - imageConfig, err := config.Parse(configData) - require.NoError(t, err) - context, err := NewContext("", "", true) require.NoError(t, err) defer func() { @@ -88,7 +103,7 @@ func TestConfigureUsers_NoUsers(t *testing.T) { }() builder := &Builder{ - imageConfig: imageConfig, + imageConfig: &config.ImageConfig{}, context: context, } diff --git a/pkg/config/image_test.go b/pkg/config/image_test.go index ea4e8145..a8587b45 100644 --- a/pkg/config/image_test.go +++ b/pkg/config/image_test.go @@ -31,7 +31,7 @@ func TestParse(t *testing.T) { assert.Equal(t, expectedKernelArgs, imageConfig.OperatingSystem.KernelArgs) userConfigs := imageConfig.OperatingSystem.Users - assert.Len(t, userConfigs, 3) + require.Len(t, userConfigs, 3) assert.Equal(t, "alpha", userConfigs[0].Username) assert.Equal(t, "$6$bZfTI3Wj05fdxQcB$W1HJQTKw/MaGTCwK75ic9putEquJvYO7vMnDBVAfuAMFW58/79abky4mx9.8znK0UZwSKng9dVosnYQR1toH71", userConfigs[0].Password) assert.Contains(t, userConfigs[0].SSHKey, "ssh-rsa AAAAB3")