(t *testing.T)
| 26 | ) |
| 27 | |
| 28 | func TestPopAllQueue(t *testing.T) { |
| 29 | s := Sender{ |
| 30 | Config: &Config{QueueCap: 10000}, |
| 31 | } |
| 32 | numInfos := 5 |
| 33 | numRoutes := 2 |
| 34 | |
| 35 | s.inputQueue = make([]chan *SwitchTrafficInfo, numRoutes) |
| 36 | |
| 37 | s.inputQueue[0] = make(chan *SwitchTrafficInfo, s.Config.QueueCap) |
| 38 | s.inputQueue[1] = make(chan *SwitchTrafficInfo, s.Config.QueueCap) |
| 39 | |
| 40 | routes := []*PathInfo{ |
| 41 | {switches: nil}, |
| 42 | {switches: nil}, |
| 43 | } |
| 44 | |
| 45 | for i := 0; i <= numInfos; i++ { |
| 46 | routeIdx := i % numRoutes |
| 47 | s.inputQueue[routeIdx] <- &SwitchTrafficInfo{ |
| 48 | hop: i, |
| 49 | routeIdx: routeIdx, |
| 50 | } |
| 51 | } |
| 52 | s.popAllQueue(routes) |
| 53 | |
| 54 | require.Equal(t, 0, routes[0].switches[0].hop) |
| 55 | require.Equal(t, 2, routes[0].switches[1].hop) |
| 56 | require.Equal(t, 4, routes[0].switches[2].hop) |
| 57 | |
| 58 | require.Equal(t, 1, routes[1].switches[0].hop) |
| 59 | require.Equal(t, 3, routes[1].switches[1].hop) |
| 60 | require.Equal(t, 5, routes[1].switches[2].hop) |
| 61 | } |
| 62 | |
| 63 | func TestClearPaths(t *testing.T) { |
| 64 | s := Sender{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…