MCPcopy Index your code
hub / github.com/docker/cli / TestRunPushRespectsNoColorForAuxNotes

Function TestRunPushRespectsNoColorForAuxNotes

cli/command/image/push_test.go:95–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestRunPushRespectsNoColorForAuxNotes(t *testing.T) {
96 t.Setenv("NO_COLOR", "1")
97 cli := test.NewFakeCli(&fakeClient{
98 imagePushFunc: func(ref string, options client.ImagePushOptions) (client.ImagePushResponse, error) {
99 aux, err := json.Marshal(auxprogress.ManifestPushedInsteadOfIndex{
100 ManifestPushedInsteadOfIndex: true,
101 OriginalIndex: ocispec.Descriptor{Digest: "sha256:1111111111111111111111111111111111111111111111111111111111111111"},
102 SelectedManifest: ocispec.Descriptor{Digest: "sha256:2222222222222222222222222222222222222222222222222222222222222222"},
103 })
104 assert.NilError(t, err)
105 line := append([]byte(`{"aux":`), aux...)
106 line = append(line, '}', '\n')
107 return fakeStreamResult{ReadCloser: io.NopCloser(bytes.NewReader(line))}, nil
108 },
109 })
110 cli.Out().SetIsTerminal(true)
111
112 err := runPush(t.Context(), cli, pushOptions{remote: "image:tag"})
113 assert.NilError(t, err)
114
115 out := cli.OutBuffer().String()
116 assert.Assert(t, strings.Contains(out, "sha256:1111111111111111111111111111111111111111111111111111111111111111 -> sha256:2222222222222222222222222222222222222222222222222222222222222222"))
117 assert.Assert(t, !strings.Contains(out, "\x1b["), "output should not contain ANSI escape codes, output: %s", out)
118}

Callers

nothing calls this directly

Calls 6

OutMethod · 0.95
OutBufferMethod · 0.95
ContainsMethod · 0.80
runPushFunction · 0.70
StringMethod · 0.65
SetIsTerminalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…