(t *testing.T)
| 264 | } |
| 265 | |
| 266 | func TestCreateAggregateFromMessageCountMap(t *testing.T) { |
| 267 | testCases := []struct { |
| 268 | name string |
| 269 | mcm MessageCountMap |
| 270 | expected Aggregate |
| 271 | }{ |
| 272 | { |
| 273 | "input has single instance of one message", |
| 274 | MessageCountMap{"abc": 1}, |
| 275 | aggregate{fmt.Errorf("abc")}, |
| 276 | }, |
| 277 | { |
| 278 | "input has multiple messages", |
| 279 | MessageCountMap{"abc": 2, "ghi": 1}, |
| 280 | aggregate{fmt.Errorf("abc (repeated 2 times)"), fmt.Errorf("ghi")}, |
| 281 | }, |
| 282 | { |
| 283 | "input has multiple messages", |
| 284 | MessageCountMap{"ghi": 1, "abc": 2}, |
| 285 | aggregate{fmt.Errorf("abc (repeated 2 times)"), fmt.Errorf("ghi")}, |
| 286 | }, |
| 287 | } |
| 288 | |
| 289 | var expected, agg []error |
| 290 | for _, testCase := range testCases { |
| 291 | t.Run(testCase.name, func(t *testing.T) { |
| 292 | if testCase.expected != nil { |
| 293 | expected = testCase.expected.Errors() |
| 294 | sort.Slice(expected, func(i, j int) bool { return expected[i].Error() < expected[j].Error() }) |
| 295 | } |
| 296 | if testCase.mcm != nil { |
| 297 | agg = CreateAggregateFromMessageCountMap(testCase.mcm).Errors() |
| 298 | sort.Slice(agg, func(i, j int) bool { return agg[i].Error() < agg[j].Error() }) |
| 299 | } |
| 300 | if !reflect.DeepEqual(expected, agg) { |
| 301 | t.Errorf("expected %v, got %v", expected, agg) |
| 302 | } |
| 303 | }) |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | func TestAggregateGoroutines(t *testing.T) { |
| 308 | testCases := []struct { |
nothing calls this directly
no test coverage detected