MCPcopy
hub / github.com/digitalocean/doctl / TestCommandName

Function TestCommandName

doit_test.go:131–153  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129}
130
131func TestCommandName(t *testing.T) {
132 t.Run("snap name set to goland", func(t *testing.T) {
133 const snapName = "goland"
134
135 t.Setenv("SNAP_NAME", snapName)
136
137 // When run under `go test`, os.Args[0] will be different every time,
138 // so only check that the Snap name is not "goland".
139 if actual := CommandName(); actual == snapName {
140 t.Errorf("expected name not to equal %s, got %s", snapName, actual)
141 }
142 })
143
144 t.Run("snap name set to doctl", func(t *testing.T) {
145 const expected = "doctl"
146
147 t.Setenv("SNAP_NAME", expected)
148
149 if actual := CommandName(); actual != expected {
150 t.Errorf("got %s, want %s", actual, expected)
151 }
152 })
153}

Callers

nothing calls this directly

Calls 3

CommandNameFunction · 0.85
ErrorfMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected