Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dekiel committed Oct 9, 2024
1 parent ffd5168 commit f6a613c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/image-builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions pkg/tags/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package tags
import (
"testing"
"time"

"go.uber.org/zap"
)

func TestTagger_ParseTags(t *testing.T) {
Expand Down Expand Up @@ -37,13 +39,19 @@ 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,
ShortSHA: "abc1234",
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 {
Expand Down

0 comments on commit f6a613c

Please sign in to comment.