The running indexer's validation before take-in asks its own manifest validator (cmd/mesh-judge under the indexer entry's Go module, at the revision's head) over two cases and refuses only what the revision causes; mesh-judge reads the file MESH_RUN_INPUT names, where a run writes its input. Builds: design 47 G §712, A-213, A-232 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/composer"
|
|
)
|
|
|
|
// A run ask writes the request to the file MESH_RUN_INPUT names and passes no argument (design 47 G §712): the validator
|
|
// reads it there and answers both cases.
|
|
func TestTheRunsInputFileIsTheRequest(t *testing.T) {
|
|
req := composer.Request{V: composer.Version, Input: json.RawMessage("{}"), Cases: []composer.Case{
|
|
{Name: "change", Manifests: map[string]composer.Manifest{}}, {Name: "trunk", Manifests: map[string]composer.Manifest{}}}}
|
|
raw, err := json.Marshal(req)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
file := filepath.Join(t.TempDir(), "input")
|
|
if err := os.WriteFile(file, raw, 0o600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Setenv(buildstep.RunInputEnv, file)
|
|
var out, errs bytes.Buffer
|
|
if code := run(nil, strings.NewReader(""), &out, &errs); code != 0 {
|
|
t.Fatalf("exit %d: %s", code, errs.String())
|
|
}
|
|
var v composer.Verdict
|
|
if err := json.Unmarshal(out.Bytes(), &v); err != nil || len(v.Cases) != 2 {
|
|
t.Fatalf("the verdict %s: %v", out.String(), err)
|
|
}
|
|
}
|