Swaps three import paths for mesh-sdk's go/catalogue, go/overlay and go/validate (the same packages, copied from this repository at 6c2a8d62) and lets gofmt order the groups. The six swap commits compile together once the pin commit (go.mod, modules.txt) is on the branch; each alone does not, because a file on the SDK's types cannot call one still on the old package.
44 lines
1.7 KiB
Go
44 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
"github.com/novox/mesh-controller/internal/inventory"
|
|
"github.com/novox/mesh-controller/internal/link"
|
|
)
|
|
|
|
func claiming(module, seat string, on ...string) inventory.Entry {
|
|
return inventory.Entry{
|
|
Manifest: catalogue.Manifest{Module: module, Claims: []catalogue.Claim{{Name: seat}}},
|
|
On: on,
|
|
}
|
|
}
|
|
|
|
// The controller asks the build role that has a holder (novox/hq ADR 0190 handover): the retired
|
|
// one while only the builder is assigned, the current one from the first build-agent on, and the
|
|
// current one when nothing holds either — where every ask goes once the handover is done.
|
|
func TestTheControllerAsksTheBuildRoleThatHasAHolder(t *testing.T) {
|
|
onlyTheBuilder := []inventory.Entry{
|
|
claiming("builder", link.TheBuildMachineBefore, "anchor"),
|
|
claiming("build-agent", link.TheBuildMachine), // registered, assigned nowhere yet
|
|
}
|
|
if got := buildSeatAmong(onlyTheBuilder); got != link.TheBuildMachineBefore {
|
|
t.Errorf("with only the builder assigned, asked %q", got)
|
|
}
|
|
bothHeld := []inventory.Entry{
|
|
claiming("builder", link.TheBuildMachineBefore, "anchor"),
|
|
claiming("build-agent", link.TheBuildMachine, "home-server"),
|
|
}
|
|
if got := buildSeatAmong(bothHeld); got != link.TheBuildMachine {
|
|
t.Errorf("with a build-agent assigned anywhere, asked %q", got)
|
|
}
|
|
neither := []inventory.Entry{claiming("builder", link.TheBuildMachineBefore)}
|
|
if got := buildSeatAmong(neither); got != link.TheBuildMachine {
|
|
t.Errorf("with no holder of either, asked %q, want the current role", got)
|
|
}
|
|
if got := buildSeatAmong(nil); got != link.TheBuildMachine {
|
|
t.Errorf("an empty catalogue asks %q", got)
|
|
}
|
|
}
|