Give back the connection name a test's in-process command line set (issue 1945)

runLine runs the controller's dispatch in the test process, which names every later connection after the line's verb:
the proposals tests left "mesh-controller verb settings", and the conditions verb's test later in the same process
read that name instead of its own.
This commit is contained in:
2026-10-24 22:37:46 +02:00
parent 183d7a99ff
commit 9abe0b59fa
@@ -9,6 +9,8 @@ import (
"testing"
"git.novox.be/novox/mesh-sdk/go/catalogue"
"github.com/novox/mesh-controller/internal/broker"
)
// Where root creates and owns a module's directories, and which of the machine's paths reach its container,
@@ -39,8 +41,10 @@ func atTheTerminal(t *testing.T, argv ...string) error {
func runLine(t *testing.T, argv []string) error {
t.Helper()
before := os.Args
defer func() { os.Args = before }()
before, named := os.Args, broker.ConnectionName
// run names every connection this process dials after the line's verb; a later test in this process would dial as
// that verb (issue 1945: a conditions test saw "mesh-controller verb settings").
defer func() { os.Args, broker.ConnectionName = before, named }()
os.Args = append([]string{"mesh-controller"}, argv...)
return run()
}