//go:build linux package host import ( "testing" "time" "github.com/carlosframework/platform/internal/hostclaim" ) // Carry 3, the install journal (Task 10 review M7): the local install // writes install.json under relocationJournals shared, so it waits while a // sweep holds the lock, and completes once the sweep lets go. func TestRelocationInstallJournalWaitsForTheSweep(t *testing.T) { f := newInstallFixture(t, nil) relocationJournals.Lock() locked := true defer func() { if locked { relocationJournals.Unlock() } }() type result struct { l hostclaim.LocalInstall err error } done := make(chan result, 1) go func() { l, err := f.install() done <- result{l, err} }() select { case r := <-done: t.Fatalf("installed beside the sweep: %+v %v", r.l, r.err) case <-time.After(500 * time.Millisecond): } relocationJournals.Unlock() locked = false if r := <-done; r.err != nil { t.Fatal(r.err) } path, _ := relocationInstallPath(f.r.DataDir, "rel-1") if _, err := relocationJournalHost(path); err != nil { t.Fatalf("the install journal: %v", err) } }