The part build-step lacks the check job's toolchain and types the check answer's fetch as the fetch arguments; both are kept in askrun_gaps.go until the part has them. Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
49 lines
2.1 KiB
Go
49 lines
2.1 KiB
Go
package buildstep
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
|
|
nodebuildgo "git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildgo"
|
|
nodebuildimage "git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildimage"
|
|
nodebuildnode "git.novox.be/novox/mesh-delivery/contracts/go/seats/nodebuildnode"
|
|
)
|
|
|
|
// The toolchains value and key are the layout all three node-build seats generate: each seat's strict decoder reads
|
|
// what the shared runner writes, and each seat's key function agrees with ToolchainKey.
|
|
func TestTheToolchainsValueAndKeyAreTheSeatsLayout(t *testing.T) {
|
|
raw, err := EncodeToolchain(Toolchain{Language: "go", Version: "go1.27.1", Recipe: "3", At: time.Date(2026, 11, 5, 10, 0, 0, 0, time.UTC)})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, err := nodebuildgo.DecodeToolchainsByNodeLanguageValue(raw); err != nil {
|
|
t.Errorf("node-build-go does not read the value: %v", err)
|
|
}
|
|
if _, err := nodebuildimage.DecodeToolchainsByNodeLanguageValue(raw); err != nil {
|
|
t.Errorf("node-build-image does not read the value: %v", err)
|
|
}
|
|
if _, err := nodebuildnode.DecodeToolchainsByNodeLanguageValue(raw); err != nil {
|
|
t.Errorf("node-build-node does not read the value: %v", err)
|
|
}
|
|
back, err := DecodeToolchain(raw)
|
|
if err != nil || back.Version != "go1.27.1" || back.At.IsZero() {
|
|
t.Errorf("the value reads back as %+v, %v", back, err)
|
|
}
|
|
key, err := ToolchainKey("ace", "typescript")
|
|
if err != nil || key != nodebuildnode.ToolchainsByNodeLanguageKey("ace", "typescript") || key != nodebuildgo.ToolchainsByNodeLanguageKey("ace", "typescript") {
|
|
t.Errorf("key %q, %v", key, err)
|
|
}
|
|
for _, bad := range [][2]string{{"", "go"}, {"a.b", "go"}, {"ace", "rust"}} {
|
|
if _, err := ToolchainKey(bad[0], bad[1]); err == nil {
|
|
t.Errorf("the key of %v was made", bad)
|
|
}
|
|
}
|
|
if _, err := EncodeToolchain(Toolchain{Language: "go", Version: "go1.27"}); err == nil {
|
|
t.Error("a toolchain without its recipe was written")
|
|
}
|
|
if _, err := DecodeToolchain([]byte(`{"v":1,"language":"go","version":"x","recipe":"1","extra":1}`)); err == nil || !strings.Contains(err.Error(), "extra") {
|
|
t.Errorf("a field the layout lacks was read: %v", err)
|
|
}
|
|
}
|