(t *testing.T)
| 100 | } |
| 101 | |
| 102 | func TestStdioAttributes(t *testing.T) { |
| 103 | outBuffer := new(bytes.Buffer) |
| 104 | errBuffer := new(bytes.Buffer) |
| 105 | t.Parallel() |
| 106 | for _, tc := range []struct { |
| 107 | test string |
| 108 | stdinTty bool |
| 109 | stdoutTty bool |
| 110 | // TODO(laurazard): test stderr |
| 111 | expected []attribute.KeyValue |
| 112 | }{ |
| 113 | { |
| 114 | test: "", |
| 115 | expected: []attribute.KeyValue{ |
| 116 | attribute.Bool("command.stdin.isatty", false), |
| 117 | attribute.Bool("command.stdout.isatty", false), |
| 118 | attribute.Bool("command.stderr.isatty", false), |
| 119 | }, |
| 120 | }, |
| 121 | { |
| 122 | test: "", |
| 123 | stdinTty: true, |
| 124 | stdoutTty: true, |
| 125 | expected: []attribute.KeyValue{ |
| 126 | attribute.Bool("command.stdin.isatty", true), |
| 127 | attribute.Bool("command.stdout.isatty", true), |
| 128 | attribute.Bool("command.stderr.isatty", false), |
| 129 | }, |
| 130 | }, |
| 131 | } { |
| 132 | t.Run(tc.test, func(t *testing.T) { |
| 133 | t.Parallel() |
| 134 | cli := &DockerCli{ |
| 135 | in: streams.NewIn(io.NopCloser(strings.NewReader(""))), |
| 136 | out: streams.NewOut(outBuffer), |
| 137 | err: streams.NewOut(errBuffer), |
| 138 | } |
| 139 | cli.In().SetIsTerminal(tc.stdinTty) |
| 140 | cli.Out().SetIsTerminal(tc.stdoutTty) |
| 141 | actual := stdioAttributes(cli) |
| 142 | |
| 143 | assert.Check(t, is.DeepEqual(actual, tc.expected, cmpopts.EquateComparable(attribute.Value{}))) |
| 144 | }) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | func TestAttributesFromError(t *testing.T) { |
| 149 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…