From d003592481096388c1fbd61194f7f3b20dcc826b Mon Sep 17 00:00:00 2001 From: cpanato Date: Mon, 4 Mar 2024 05:45:18 -0500 Subject: [PATCH] update test Signed-off-by: cpanato --- internal/config/config_test.go | 5 ++++- pkg/version/version_test.go | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 0d1ffcf6..f13e0c6e 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -86,7 +86,10 @@ func TestGet(t *testing.T) { RedirectURL: "example.com", ConnectorID: "bar", RekorMode: "online", - LogPath: "/tmp/gitsign.log", + } + + if os.Getenv("GITSIGN_LOG") != "" { + want.LogPath = os.Getenv("GITSIGN_LOG") } execFn = func() (io.Reader, error) { diff --git a/pkg/version/version_test.go b/pkg/version/version_test.go index ccaf67ec..e1358f95 100644 --- a/pkg/version/version_test.go +++ b/pkg/version/version_test.go @@ -16,6 +16,7 @@ package version import ( + "fmt" "os" "testing" @@ -30,17 +31,22 @@ func TestVersionText(t *testing.T) { } func TestEnv(t *testing.T) { + if os.Getenv("GITSIGN_LOG") == "" { + os.Setenv("GITSIGN_LOG", "") + } os.Setenv("GITSIGN_CONNECTOR_ID", "foobar") os.Setenv("GITSIGN_TEST", "foo") os.Setenv("TUF_ROOT", "bar") - got := GetVersionInfo() + want := []string{ - "GITSIGN_LOG=/tmp/gitsign.log", + fmt.Sprintf("GITSIGN_LOG=%s", os.Getenv("GITSIGN_LOG")), "GITSIGN_CONNECTOR_ID=foobar", "GITSIGN_TEST=foo", "TUF_ROOT=bar", } + got := GetVersionInfo() + if diff := cmp.Diff(got.Env, want); diff != "" { t.Error(diff) }