| 1 | package workbench |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | "time" |
| 6 | ) |
| 7 | |
| 8 | func TestWindowsAdmissionJoinsStartedTimeout(t *testing.T) { |
| 9 | started, release, finished := make(chan struct{}), make(chan struct{}), make(chan struct{}) |
| 10 | timer := time.AfterFunc(0, func() { close(started); <-release; close(finished) }) |
| 11 | <-started |
| 12 | result := make(chan bool) |
| 13 | go func() { result <- cancelWindowsAdmissionDeadline(timer, finished) }() |
| 14 | select { |
| 15 | case <-result: |
| 16 | t.Fatal("admission returned while late timeout could still kill relay") |
| 17 | default: |
| 18 | } |
| 19 | close(release) |
| 20 | if <-result { |
| 21 | t.Fatal("expired connection was published") |
| 22 | } |
| 23 | select { |
| 24 | case <-finished: |
| 25 | default: |
| 26 | t.Fatal("timeout callback not joined") |
| 27 | } |
| 28 | } |