From e4a25a9903cafaaa1ce0c898d6088e4454362ef8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Golicz?= Date: Sun, 15 Dec 2024 13:40:53 +0100 Subject: [PATCH] adding one more converter unit test for emoty auditlog data when create --- pkg/gardener/shoot/converter_test.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/gardener/shoot/converter_test.go b/pkg/gardener/shoot/converter_test.go index c1d0c606..e97014eb 100644 --- a/pkg/gardener/shoot/converter_test.go +++ b/pkg/gardener/shoot/converter_test.go @@ -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() @@ -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()