aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/model/plan_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'gui/internal/model/plan_test.go')
-rw-r--r--gui/internal/model/plan_test.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/gui/internal/model/plan_test.go b/gui/internal/model/plan_test.go
index 241a049..3b3d7b9 100644
--- a/gui/internal/model/plan_test.go
+++ b/gui/internal/model/plan_test.go
@@ -487,9 +487,10 @@ func TestCloseDuringApplyIsRefused(t *testing.T) {
// Hold the apply open while Close is attempted.
<-done
}
- var applyErr error
+ finished := make(chan error, 1)
go func() {
- _, applyErr = tab.Apply(context.Background())
+ _, err := tab.Apply(context.Background())
+ finished <- err
}()
<-started
@@ -497,12 +498,15 @@ func TestCloseDuringApplyIsRefused(t *testing.T) {
t.Error("Close during an apply was allowed: the lock and the log go out from under it")
}
close(done)
- // Let the apply finish before the sandbox is torn down.
- for i := 0; i < 200 && !tab.Applied; i++ {
- time.Sleep(10 * time.Millisecond)
- }
- if applyErr != nil {
- t.Errorf("the apply itself failed: %v", applyErr)
+ // Wait for the apply rather than polling its fields: the real window
+ // hears about it on the main loop, which orders the writes.
+ select {
+ case err := <-finished:
+ if err != nil {
+ t.Errorf("the apply itself failed: %v", err)
+ }
+ case <-time.After(30 * time.Second):
+ t.Fatal("the apply never finished")
}
}