Skip to content

Commit

Permalink
test(manifest): replace os.Setenv with t.Setenv to improve test caching
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Jun 15, 2023
1 parent 7971b91 commit a0248b3
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions pkg/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,7 @@ func TestManifestPrepend(t *testing.T) {
}

func TestDataServiceID(t *testing.T) {
sid := os.Getenv(env.ServiceID)
defer func(sid string) {
os.Setenv(env.ServiceID, sid)
}(sid)

err := os.Setenv(env.ServiceID, "001")
if err != nil {
t.Fatal(err)
}
t.Setenv(env.ServiceID, "001")

// SourceFlag
d := manifest.Data{
Expand All @@ -232,10 +224,7 @@ func TestDataServiceID(t *testing.T) {
}

// SourceFile
err = os.Setenv(env.ServiceID, "")
if err != nil {
t.Fatal(err)
}
t.Setenv(env.ServiceID, "")
_, src = d.ServiceID()
if src != manifest.SourceFile {
t.Fatal("expected SourceFile")
Expand Down

0 comments on commit a0248b3

Please sign in to comment.