Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato committed Mar 4, 2024
1 parent 220715a commit d003592
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion internal/config/config_test.go
Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions pkg/version/version_test.go
Expand Up @@ -16,6 +16,7 @@
package version

import (
"fmt"
"os"
"testing"

Expand All @@ -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)
}
Expand Down

0 comments on commit d003592

Please sign in to comment.