The controller tells mesh-config what a pull request declares, asks the approved held values with each check, and the build agent and merge gate lay them over the change's composition only: a key the trunk does not declare yet can then be approved before the merge (ADR 0502).
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package builder
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// 1826/AC2: the held values are written whole to held.json, and the gate is given the flag only when there are some.
|
|
func TestHeldValuesAreWrittenForTheGateAndNoneWriteNothing(t *testing.T) {
|
|
root := t.TempDir()
|
|
if file, err := writeHeld(root, nil); err != nil || file != "" {
|
|
t.Fatalf("none wrote %q %v", file, err)
|
|
}
|
|
if _, err := os.Stat(filepath.Join(root, "held.json")); err == nil {
|
|
t.Fatal("none wrote a file")
|
|
}
|
|
file, err := writeHeld(root, []HeldValue{{Pull: "novox/mesh-catalog#434", Node: "ace", Module: "n8n", Key: "media-gid",
|
|
Value: []byte("2000"), Approved: "the operator"}})
|
|
if err != nil || file != filepath.Join(root, "held.json") {
|
|
t.Fatalf("wrote %q %v", file, err)
|
|
}
|
|
raw, _ := os.ReadFile(file)
|
|
for _, want := range []string{`"node":"ace"`, `"module":"n8n"`, `"key":"media-gid"`, `"value":2000`} {
|
|
if !strings.Contains(string(raw), want) {
|
|
t.Fatalf("%s lacks %s", raw, want)
|
|
}
|
|
}
|
|
if !strings.Contains(heldFlag, `--held "$MESH_CHECK_HELD"`) || !strings.HasPrefix(heldFlag, "${MESH_CHECK_HELD:+") {
|
|
t.Fatalf("the flag is %s", heldFlag)
|
|
}
|
|
}
|