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

Function TestNamespacesList

commands/namespaces_test.go:154–182  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

152}
153
154func TestNamespacesList(t *testing.T) {
155 withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
156 buf := &bytes.Buffer{}
157 config.Out = buf
158
159 returnedList := do.NamespaceListResponse{Namespaces: []do.OutputNamespace{
160 {
161 Label: "my_dog",
162 Namespace: "ns1",
163 Region: "lon1",
164 APIHost: "https://lon1.example.com",
165 },
166 {
167 Label: "something",
168 Namespace: "ns2",
169 Region: "sgp1",
170 APIHost: "https://sgp1.example.com",
171 },
172 }}
173 expectedOutput := "Label Region Namespace ID API Host\nmy_dog lon1 ns1 https://lon1.example.com\nsomething sgp1 ns2 https://sgp1.example.com\n"
174
175 tm.serverless.EXPECT().ListNamespaces(context.TODO()).Return(returnedList, nil)
176
177 err := RunNamespacesList(config)
178
179 require.NoError(t, err)
180 assert.Equal(t, expectedOutput, buf.String())
181 })
182}
183
184func TestNamespacesDelete(t *testing.T) {
185 tests := []struct {

Callers

nothing calls this directly

Calls 5

withTestClientFunction · 0.85
RunNamespacesListFunction · 0.85
ListNamespacesMethod · 0.65
EXPECTMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected