Give back everything serve sets once the served tests' controller stops (issue 1945)
The served mark in the environment made every later test in the process read as the serving controller's: the registration test was refused as "never through a verb". The fixture now restores the mark, the hand-act log's connection, the keeper, the status and the event publishers serve sets.
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/novox/mesh-controller/internal/chain"
|
||||
"github.com/novox/mesh-controller/internal/identity"
|
||||
"github.com/novox/mesh-controller/internal/inventory"
|
||||
"github.com/novox/mesh-controller/internal/link"
|
||||
)
|
||||
|
||||
// The compositions through the controller whole (novox/hq ADR 0539; the review's G1): the real store, the controller's
|
||||
@@ -220,6 +221,7 @@ func aServedMesh(t *testing.T) *servedMesh {
|
||||
}
|
||||
}
|
||||
|
||||
keepWhatServeSets(t)
|
||||
serving, stop := context.WithCancel(context.Background())
|
||||
done := make(chan error, 1)
|
||||
go func() { done <- serve(serving) }()
|
||||
@@ -587,3 +589,18 @@ func capturedOutput(act func() error) (string, error) {
|
||||
w.Close()
|
||||
return <-done, actErr
|
||||
}
|
||||
|
||||
// keepWhatServeSets gives back, once the served controller stopped, what serve sets for the rest of its process, which
|
||||
// a controller's process exits after and the test process does not (issue 1945): the served mark in the environment, the
|
||||
// hand-act log's connection, the keeper, the status and the event publishers. Registered before the controller starts, so
|
||||
// it runs after the cleanup that stops it.
|
||||
func keepWhatServeSets(t *testing.T) {
|
||||
t.Helper()
|
||||
t.Setenv(servedVar, "")
|
||||
unheld, status, given, check, follow, keeper, hand := logUnheldChanges, statusFrom, givenEvents, checkEvents,
|
||||
link.Calls.Follow, conditionsFrom, handActConn
|
||||
t.Cleanup(func() {
|
||||
logUnheldChanges, statusFrom, givenEvents, checkEvents, link.Calls.Follow, conditionsFrom, handActConn =
|
||||
unheld, status, given, check, follow, keeper, hand
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user