Skip to content

Commit

Permalink
Updates based on PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jdob committed Nov 17, 2023
1 parent 1adc164 commit 4b67e1b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
5 changes: 0 additions & 5 deletions pkg/build/testdata/minimal-test-definition.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions pkg/build/testdata/users-test-definition.yaml

This file was deleted.

35 changes: 25 additions & 10 deletions pkg/build/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -76,19 +96,14 @@ 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() {
assert.NoError(t, CleanUpBuildDir(context))
}()

builder := &Builder{
imageConfig: imageConfig,
imageConfig: &config.ImageConfig{},
context: context,
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 4b67e1b

Please sign in to comment.