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

Function TestStdioAttributes

cli/command/telemetry_utils_test.go:102–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func 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
148func TestAttributesFromError(t *testing.T) {
149 t.Parallel()

Callers

nothing calls this directly

Calls 4

InMethod · 0.95
OutMethod · 0.95
stdioAttributesFunction · 0.85
SetIsTerminalMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…