(t *testing.T)
| 29 | } |
| 30 | |
| 31 | func TestRegisterServerLocation(t *testing.T) { |
| 32 | m := newTunnelMetrics() |
| 33 | tunnels := 20 |
| 34 | var wg sync.WaitGroup |
| 35 | wg.Add(tunnels) |
| 36 | for i := 0; i < tunnels; i++ { |
| 37 | go func(i int) { |
| 38 | id := strconv.Itoa(i) |
| 39 | m.registerServerLocation(id, "LHR") |
| 40 | wg.Done() |
| 41 | }(i) |
| 42 | } |
| 43 | wg.Wait() |
| 44 | for i := 0; i < tunnels; i++ { |
| 45 | id := strconv.Itoa(i) |
| 46 | assert.Equal(t, "LHR", m.oldServerLocations[id]) |
| 47 | } |
| 48 | |
| 49 | wg.Add(tunnels) |
| 50 | for i := 0; i < tunnels; i++ { |
| 51 | go func(i int) { |
| 52 | id := strconv.Itoa(i) |
| 53 | m.registerServerLocation(id, "AUS") |
| 54 | wg.Done() |
| 55 | }(i) |
| 56 | } |
| 57 | wg.Wait() |
| 58 | for i := 0; i < tunnels; i++ { |
| 59 | id := strconv.Itoa(i) |
| 60 | assert.Equal(t, "AUS", m.oldServerLocations[id]) |
| 61 | } |
| 62 | |
| 63 | } |
| 64 | |
| 65 | func TestObserverEventsDontBlock(t *testing.T) { |
| 66 | observer := NewObserver(&log, &log) |
nothing calls this directly
no test coverage detected