From f6a613c61d7600e31bb5ae849623a21913ce8309 Mon Sep 17 00:00:00 2001 From: dekiel Date: Wed, 9 Oct 2024 08:50:16 +0200 Subject: [PATCH] Fixed tests --- cmd/image-builder/main_test.go | 8 ++++---- pkg/tags/tags_test.go | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/image-builder/main_test.go b/cmd/image-builder/main_test.go index b881e81eabf2..6ebc6e094cb9 100644 --- a/cmd/image-builder/main_test.go +++ b/cmd/image-builder/main_test.go @@ -248,7 +248,7 @@ func TestFlags(t *testing.T) { configPath: "/config/image-builder-config.yaml", dockerfile: "dockerfile", logDir: "/logs/artifacts", - tagsOutputFile: "/generated-tags.json", + tagsOutputFile: "/tmp/generated-tags.json", }, expectedErr: true, args: []string{ @@ -270,7 +270,7 @@ func TestFlags(t *testing.T) { logDir: "prow/logs", orgRepo: "kyma-project/test-infra", silent: true, - tagsOutputFile: "/generated-tags.json", + tagsOutputFile: "/tmp/generated-tags.json", }, args: []string{ "--config=config.yaml", @@ -292,7 +292,7 @@ func TestFlags(t *testing.T) { dockerfile: "dockerfile", logDir: "/logs/artifacts", exportTags: true, - tagsOutputFile: "/generated-tags.json", + tagsOutputFile: "/tmp/generated-tags.json", }, args: []string{ "--export-tags", @@ -309,7 +309,7 @@ func TestFlags(t *testing.T) { tags.Tag{Name: "BIN", Value: "test"}, tags.Tag{Name: "BIN2", Value: "test2"}, }, - tagsOutputFile: "/generated-tags.json", + tagsOutputFile: "/tmp/generated-tags.json", }, args: []string{ "--build-arg=BIN=test", diff --git a/pkg/tags/tags_test.go b/pkg/tags/tags_test.go index ff2d99bea7dd..8699315b481e 100644 --- a/pkg/tags/tags_test.go +++ b/pkg/tags/tags_test.go @@ -3,6 +3,8 @@ package tags import ( "testing" "time" + + "go.uber.org/zap" ) func TestTagger_ParseTags(t *testing.T) { @@ -37,6 +39,11 @@ func TestTagger_ParseTags(t *testing.T) { } for _, c := range tc { t.Run(c.name, func(t *testing.T) { + zapLogger, err := zap.NewDevelopment() + if err != nil { + t.Errorf("error creating zap logger: %v", err) + } + logger := zapLogger.Sugar() t.Setenv("test-var", "test") tag := Tagger{ tags: c.template, @@ -44,6 +51,7 @@ func TestTagger_ParseTags(t *testing.T) { CommitSHA: "f1c7ca0b532141898f56c1843ae60ebec3a75a85", Time: time.Now(), Date: time.Date(2022, 06, 02, 01, 01, 01, 1, time.Local).Format("20060102"), + logger: logger, } got, err := tag.ParseTags() if err != nil {