mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-23 20:25:56 +00:00
Close the harness command client before Windows removes its state dir
Since #2550, three command identity tests fail on Windows x64: TempDir cleanup cannot delete operation-receipts.db because the agent's command client still holds it open. Those tests never call run, so nothing closes the client that New built, and Windows refuses to delete an open file. Other platforms delete it anyway. Stop and close the command client in a harness cleanup. It is registered after the state TempDir, so it runs first, and Close is idempotent for the tests that do run the agent. Production already closes the client when Run exits or an identity supersedes it.
This commit is contained in:
@@ -601,6 +601,10 @@ func newCommandIdentityHarness(t *testing.T, presentedID string, interval time.D
|
||||
agent.httpClient = h.server.Client()
|
||||
agent.trimmedPulseURL = h.server.URL
|
||||
h.agent = agent
|
||||
// Run closes the command client on exit, but several tests never call
|
||||
// run. Close it here, before the state TempDir is removed: Windows cannot
|
||||
// delete the open operation-receipts.db.
|
||||
t.Cleanup(func() { agent.stopCommandClient(true) })
|
||||
return h
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user