| 93 | } |
| 94 | |
| 95 | func 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 | } |