(t *testing.T)
| 146 | } |
| 147 | |
| 148 | func TestAttributesFromError(t *testing.T) { |
| 149 | t.Parallel() |
| 150 | |
| 151 | for _, tc := range []struct { |
| 152 | testName string |
| 153 | err error |
| 154 | expected []attribute.KeyValue |
| 155 | }{ |
| 156 | { |
| 157 | testName: "no error", |
| 158 | err: nil, |
| 159 | expected: []attribute.KeyValue{ |
| 160 | attribute.Int("command.status.code", 0), |
| 161 | }, |
| 162 | }, |
| 163 | { |
| 164 | testName: "non-0 exit code", |
| 165 | err: statusError{StatusCode: 127}, |
| 166 | expected: []attribute.KeyValue{ |
| 167 | attribute.String("command.error.type", "generic"), |
| 168 | attribute.Int("command.status.code", 127), |
| 169 | }, |
| 170 | }, |
| 171 | { |
| 172 | testName: "canceled", |
| 173 | err: context.Canceled, |
| 174 | expected: []attribute.KeyValue{ |
| 175 | attribute.String("command.error.type", "canceled"), |
| 176 | attribute.Int("command.status.code", 1), |
| 177 | }, |
| 178 | }, |
| 179 | } { |
| 180 | t.Run(tc.testName, func(t *testing.T) { |
| 181 | t.Parallel() |
| 182 | actual := attributesFromError(tc.err) |
| 183 | assert.Check(t, is.DeepEqual(actual, tc.expected, cmpopts.EquateComparable(attribute.Value{}))) |
| 184 | }) |
| 185 | } |
| 186 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…