(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func TestNodeBackendReadiness(t *testing.T) { |
| 19 | nb := newNodeBackend(t.Context(), tstest.WhileTestRunningLogger(t), eventbus.New()) |
| 20 | |
| 21 | // The node backend is not ready until [nodeBackend.ready] is called, |
| 22 | // and [nodeBackend.Wait] should fail with [context.DeadlineExceeded]. |
| 23 | ctx, cancelCtx := context.WithTimeout(context.Background(), 100*time.Millisecond) |
| 24 | defer cancelCtx() |
| 25 | if err := nb.Wait(ctx); err != ctx.Err() { |
| 26 | t.Fatalf("Wait: got %v; want %v", err, ctx.Err()) |
| 27 | } |
| 28 | |
| 29 | // Start a goroutine to wait for the node backend to become ready. |
| 30 | waitDone := make(chan struct{}) |
| 31 | go func() { |
| 32 | if err := nb.Wait(context.Background()); err != nil { |
| 33 | t.Errorf("Wait: got %v; want nil", err) |
| 34 | } |
| 35 | close(waitDone) |
| 36 | }() |
| 37 | |
| 38 | // Call [nodeBackend.ready] to indicate that the node backend is now ready. |
| 39 | go nb.ready() |
| 40 | |
| 41 | // Once the backend is called, [nodeBackend.Wait] should return immediately without error. |
| 42 | if err := nb.Wait(context.Background()); err != nil { |
| 43 | t.Fatalf("Wait: got %v; want nil", err) |
| 44 | } |
| 45 | // And any pending waiters should also be unblocked. |
| 46 | <-waitDone |
| 47 | } |
| 48 | |
| 49 | func TestNodeBackendShutdown(t *testing.T) { |
| 50 | nb := newNodeBackend(t.Context(), tstest.WhileTestRunningLogger(t), eventbus.New()) |
nothing calls this directly
no test coverage detected
searching dependent graphs…