MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / TestCreateAggregateFromMessageCountMap

Function TestCreateAggregateFromMessageCountMap

pkg/util/errors/errors_test.go:266–305  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

264}
265
266func 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
307func TestAggregateGoroutines(t *testing.T) {
308 testCases := []struct {

Callers

nothing calls this directly

Calls 5

ErrorfMethod · 0.80
RunMethod · 0.65
ErrorsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected