Files
archie/internal/releaseupdate
sam b11086e926 test(releaseupdate): fix a data race and a sleep in the install-cancellation test
Found by a full-repo 'go test -race ./...' sweep. internal/releaseupdate was
the only package that failed it.

The race: blockingInstallerStub.Install assigned s.gotCancelled lazily --

    if s.gotCancelled == nil { s.gotCancelled = make(chan struct{}) }

Install runs on the caller's goroutine (Service.Install calls it), while the
test goroutine reads s.gotCancelled. Two goroutines, one unsynchronised field.
The channel is now built by a newBlockingInstallerStub constructor, so no
goroutine ever writes it after the stub is handed to the test. Fixing it at
the producer rather than guarding the read.

The sleep: the test asserted 'the installer did not observe cancellation' with

    select { case <-s.gotCancelled: ... case <-time.After(50*time.Millisecond): }

which is a race against the clock to prove a negative, and is weaker than the
thing it stands in for -- a channel nothing has closed is simply not ready.
It is now a select/default, asserted synchronously.

The assertion was also unfalsifiable in one direction: if the channel were
never closed at all, the old test passed for the wrong reason. It now also
asserts the positive half -- after Install returns, the detached context is
released, so the observer MUST have fired -- which is what makes the negative
check meaningful.

A second constructor of the same stub is updated too; it relied on the lazy
assignment and would have closed a nil channel.

Reproduced before the fix (race detector, same test):
  WARNING: DATA RACE ... service_test.go:201
  --- FAIL: TestServiceInstallSurvivesCallerContextCancellation
After: 3/3 clean runs under -race.
2026-09-14 10:14:27 +00:00
..
2026-08-05 10:48:51 +10:00