diff --git a/cmd/mesh-controller/new_module_on_merge_test.go b/cmd/mesh-controller/new_module_on_merge_test.go index a022c869..9dc955ea 100644 --- a/cmd/mesh-controller/new_module_on_merge_test.go +++ b/cmd/mesh-controller/new_module_on_merge_test.go @@ -4,6 +4,7 @@ package main import ( "context" + "sync" "testing" "git.novox.be/novox/mesh-sdk/go/catalogue" @@ -11,12 +12,16 @@ import ( "github.com/novox/mesh-controller/internal/link" ) -// asksWithPaths records every build a merge asks for, as repository, path and ref. +// asksWithPaths records every build a merge asks for, as repository, path and ref. The merge window's goroutine and +// the test's own may ask at once, so the record is written under a lock (issue 1543). func asksWithPaths(t *testing.T) *[][3]string { t.Helper() var asked [][3]string + var mu sync.Mutex was := askABuild askABuild = func(_ context.Context, source buildSource, path, ref string) (string, error) { + mu.Lock() + defer mu.Unlock() asked = append(asked, [3]string{source.Repository, path, ref}) return "b-" + path, nil }