| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | "time" |
| 6 | ) |
| 7 | |
| 8 | func TestSessionCatalogInitialReconcileSignalFollowsRestoredTabs(t *testing.T) { |
| 9 | isolateDesktopUserDirs(t) |
| 10 | app := NewApp() |
| 11 | app.tabsRestored = make(chan struct{}) |
| 12 | app.startSessionCatalog() |
| 13 | t.Cleanup(func() { app.stopSessionCatalog(time.Second) }) |
| 14 | _ = waitForSessionCatalogForTest(t, app, nil) |
| 15 | |
| 16 | app.catalogLifecycleMu.Lock() |
| 17 | done := app.catalogInitialReconcileDone |
| 18 | app.catalogLifecycleMu.Unlock() |
| 19 | if done == nil { |
| 20 | t.Fatal("initial reconcile signal was not armed") |
| 21 | } |
| 22 | select { |
| 23 | case <-done: |
| 24 | t.Fatal("initial reconcile completed before restored tabs were published") |
| 25 | default: |
| 26 | } |
| 27 | |
| 28 | app.markTabsRestored() |
| 29 | select { |
| 30 | case <-done: |
| 31 | case <-time.After(sessionCatalogTestDeadline): |
| 32 | t.Fatal("initial reconcile did not complete after restored tabs were published") |
| 33 | } |
| 34 | } |
| 35 |