An entry whose fingerprint names a toolchain version of its language other than the agreed one is held in the state waits (one key <module>.<fingerprint>), says wait-held and wait-ended (ran when the agreed toolchain names the version, released by builder_release) on its stream waits, says wait-held again for every key at its start; builder_waits and builder_release; its setting toolchain-wait-minutes. Not built: the bound's finding toolchain-waits (its scope is not in the design). Builds: design 47 G §672, §267, §276, §633 Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
47 lines
2.1 KiB
Go
47 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
"git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshhandactsclient"
|
|
|
|
"mesh-delivery-builder/internal/build"
|
|
"mesh-delivery-builder/internal/versions"
|
|
)
|
|
|
|
// Design 47 G §276, §672: builder_waits lists the held entries; builder_release records the hand act first and asks the
|
|
// builder through reasks, whose refusal is the tool's error.
|
|
func TestWaitsToolsListTheWaitsAndReleaseAfterTheHandAct(t *testing.T) {
|
|
wait, _ := json.Marshal(build.ToolchainWait{Module: "m", Fingerprint: "src2:" + strings.Repeat("1", 64), Language: "go", Version: "go1.26.0", Since: time.Now()})
|
|
rr := versions.Reader{Keys: func() ([]string, error) { return []string{"m.k"}, nil },
|
|
Get: func(string) (json.RawMessage, bool, error) { return wait, true, nil }}
|
|
var asked []build.ReAsk
|
|
answer := func(key string, value []byte) (json.RawMessage, error) {
|
|
a, _ := build.DecodeReAsk(value)
|
|
asked = append(asked, a)
|
|
a.Answered, a.Answer = time.Now(), "released: built"
|
|
return json.Marshal(a)
|
|
}
|
|
recorded := 0
|
|
acts := meshhandactsclient.Recorder{Ask: func(string, any) (json.RawMessage, error) { recorded++; return json.RawMessage(`{}`), nil }}
|
|
tools := waitsTools(rr, answer, time.Now, acts)
|
|
byName := map[string]func(map[string]any) (any, error){}
|
|
for _, tl := range tools {
|
|
byName[tl.Name] = tl.Run
|
|
}
|
|
got, err := byName[build.WaitsTool](nil)
|
|
if rows := got.(map[string]any)["waits"].([]build.ToolchainWait); err != nil || len(rows) != 1 || rows[0].On() != "toolchain:go@go1.26.0" {
|
|
t.Fatalf("waits = %v, %v", got, err)
|
|
}
|
|
if _, err := byName[build.ReleaseTool](map[string]any{"module": "m", "fp": "src2:" + strings.Repeat("1", 64), "why": ""}); err == nil || recorded != 0 {
|
|
t.Fatalf("a release with no why was taken: %v, %d recorded", err, recorded)
|
|
}
|
|
if _, err := byName[build.ReleaseTool](map[string]any{"module": "m", "fp": "src2:" + strings.Repeat("1", 64), "why": "the build module runs"}); err != nil ||
|
|
recorded != 1 || len(asked) != 1 || asked[0].Mode != build.ModeRelease || asked[0].Module != "m" {
|
|
t.Fatalf("release: %v, %d recorded, asked %+v", err, recorded, asked)
|
|
}
|
|
}
|