Ensure there are no data races
(t *testing.T)
| 3008 | |
| 3009 | // Ensure there are no data races |
| 3010 | func TestDiffRace(t *testing.T) { |
| 3011 | t.Parallel() |
| 3012 | |
| 3013 | expected := map[string]string{ |
| 3014 | "a": "A", |
| 3015 | "b": "B", |
| 3016 | "c": "C", |
| 3017 | } |
| 3018 | |
| 3019 | actual := map[string]string{ |
| 3020 | "d": "D", |
| 3021 | "e": "E", |
| 3022 | "f": "F", |
| 3023 | } |
| 3024 | |
| 3025 | // run diffs in parallel simulating tests with t.Parallel() |
| 3026 | numRoutines := 10 |
| 3027 | rChans := make([]chan string, numRoutines) |
| 3028 | for idx := range rChans { |
| 3029 | rChans[idx] = make(chan string) |
| 3030 | go func(ch chan string) { |
| 3031 | defer close(ch) |
| 3032 | ch <- diff(expected, actual) |
| 3033 | }(rChans[idx]) |
| 3034 | } |
| 3035 | |
| 3036 | for _, ch := range rChans { |
| 3037 | for msg := range ch { |
| 3038 | NotZero(t, msg) // dummy assert |
| 3039 | } |
| 3040 | } |
| 3041 | } |
| 3042 | |
| 3043 | type mockTestingT struct { |
| 3044 | errorFmt string |