Skip to content

Commit

Permalink
Merge branch 'main' into refactor-ioutil-io-os
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething authored Oct 3, 2023
2 parents 9f892ed + 59e4c38 commit c3eaa68
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions doit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,34 +132,22 @@ func TestCommandName(t *testing.T) {
t.Run("snap name set to goland", func(t *testing.T) {
const snapName = "goland"

if err := os.Setenv("SNAP_NAME", snapName); err != nil {
t.Errorf("failed to set environment variable: %#v", err)
}
t.Setenv("SNAP_NAME", snapName)

// When run under `go test`, os.Args[0] will be different every time,
// so only check that the Snap name is not "goland".
if actual := CommandName(); actual == snapName {
t.Errorf("expected name not to equal %s, got %s", snapName, actual)
}

if err := os.Unsetenv("SNAP_NAME"); err != nil {
t.Errorf("failed to unset environment variable: %#v", err)
}
})

t.Run("snap name set to doctl", func(t *testing.T) {
const expected = "doctl"

if err := os.Setenv("SNAP_NAME", "doctl"); err != nil {
t.Errorf("failed to set environment variable: %#v", err)
}
t.Setenv("SNAP_NAME", expected)

if actual := CommandName(); actual != expected {
t.Errorf("got %s, want %s", actual, expected)
}

if err := os.Unsetenv("SNAP_NAME"); err != nil {
t.Errorf("failed to unset environment variable: %#v", err)
}
})
}

0 comments on commit c3eaa68

Please sign in to comment.