Ensure there are no data races
(t *testing.T)
| 2613 | |
| 2614 | // Ensure there are no data races |
| 2615 | func TestDiffRace(t *testing.T) { |
| 2616 | t.Parallel() |
| 2617 | |
| 2618 | expected := map[string]string{ |
| 2619 | "a": "A", |
| 2620 | "b": "B", |
| 2621 | "c": "C", |
| 2622 | } |
| 2623 | |
| 2624 | actual := map[string]string{ |
| 2625 | "d": "D", |
| 2626 | "e": "E", |
| 2627 | "f": "F", |
| 2628 | } |
| 2629 | |
| 2630 | // run diffs in parallel simulating tests with t.Parallel() |
| 2631 | numRoutines := 10 |
| 2632 | rChans := make([]chan string, numRoutines) |
| 2633 | for idx := range rChans { |
| 2634 | rChans[idx] = make(chan string) |
| 2635 | go func(ch chan string) { |
| 2636 | defer close(ch) |
| 2637 | ch <- diff(expected, actual) |
| 2638 | }(rChans[idx]) |
| 2639 | } |
| 2640 | |
| 2641 | for _, ch := range rChans { |
| 2642 | for msg := range ch { |
| 2643 | NotZero(t, msg) // dummy assert |
| 2644 | } |
| 2645 | } |
| 2646 | } |
| 2647 | |
| 2648 | type mockTestingT struct { |
| 2649 | errorFmt string |