Skip to content

Commit

Permalink
adding one more converter unit test for emoty auditlog data when create
Browse files Browse the repository at this point in the history
  • Loading branch information
koala7659 committed Dec 15, 2024
1 parent 7ddba31 commit e4a25a9
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion pkg/gardener/shoot/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

func TestConverter(t *testing.T) {
t.Run("Create shoot from Runtime", func(t *testing.T) {
t.Run("Create shoot from Runtime with valid Auditlog Configuration", func(t *testing.T) {
// given
runtime := fixRuntime()
converterConfig := fixConverterConfig()
Expand Down Expand Up @@ -49,6 +49,31 @@ func TestConverter(t *testing.T) {
require.Equalf(t, 5, extensionLen, "unexpected number of extensions: %d, expected: 5", extensionLen)
})

t.Run("Create shoot from Runtime with empty Auditlog Configuration", func(t *testing.T) {
// given
runtime := fixRuntime()
converterConfig := fixConverterConfig()
emptyAuditLogData := auditlogs.AuditLogData{}

converter := NewConverterCreate(CreateOpts{
ConverterConfig: converterConfig,
AuditLogData: emptyAuditLogData,
})

// when
shoot, err := converter.ToShoot(runtime)

// then
require.NoError(t, err)
assertShootFields(t, runtime, shoot)
assert.Equal(t, "1.28", shoot.Spec.Kubernetes.Version)
assert.Equal(t, "gardenlinux", shoot.Spec.Provider.Workers[0].Machine.Image.Name)
assert.Equal(t, "1591.1.0", *shoot.Spec.Provider.Workers[0].Machine.Image.Version)

extensionLen := len(shoot.Spec.Extensions)
require.Equalf(t, 4, extensionLen, "unexpected number of extensions: %d, expected: 4", extensionLen)
})

t.Run("Create shoot with default converter config versions", func(t *testing.T) {
// given
runtime := fixRuntimeWithNoVersionsSpecified()
Expand Down

0 comments on commit e4a25a9

Please sign in to comment.