MCPcopy
hub / github.com/docker/docker-agent / TestRunAliasListCommand_JSONFormatEmpty

Function TestRunAliasListCommand_JSONFormatEmpty

cmd/root/alias_test.go:51–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestRunAliasListCommand_JSONFormatEmpty(t *testing.T) {
52 // Not parallel: SetConfigDir mutates process-global state.
53 dir := t.TempDir()
54 paths.SetConfigDir(dir)
55 t.Cleanup(func() { paths.SetConfigDir("") })
56
57 var buf bytes.Buffer
58 cmd := &cobra.Command{}
59 cmd.SetOut(&buf)
60 require.NoError(t, runAliasListCommand(cmd, nil, true))
61
62 // With no aliases the JSON output is an empty array, never "null".
63 var entries []aliasListEntry
64 require.NoError(t, json.Unmarshal(buf.Bytes(), &entries))
65 assert.Empty(t, entries)
66 assert.Equal(t, "[]", string(bytes.TrimSpace(buf.Bytes())))
67}

Callers

nothing calls this directly

Calls 4

BytesMethod · 0.95
SetConfigDirFunction · 0.92
runAliasListCommandFunction · 0.85
CleanupMethod · 0.65

Tested by

no test coverage detected