package link import "testing" // A build machine serves the seat its credential claims (novox/hq ADR 0190 handover): the old // `builder` keeps the old role, a `build-agent` takes the new, from one binary and no flag. func TestABuildMachineServesTheSeatItsCredentialClaims(t *testing.T) { if got := BuildSeatClaimed([]string{"mesh-build-machine"}); got != "mesh-build-machine" { t.Errorf("a credential claiming the old role serves %q", got) } if got := BuildSeatClaimed([]string{"node-build-agent"}); got != TheBuildMachine { t.Errorf("a credential claiming the new role serves %q", got) } if got := BuildSeatClaimed(nil); got != TheBuildMachine { t.Errorf("a credential claiming nothing serves %q, want the current role", got) } if got := BuildSeatClaimed([]string{"", "node-build-agent"}); got != TheBuildMachine { t.Errorf("an empty claim is skipped; got %q", got) } } // What a machine says about a build is the event of the seat it took the build from, so an outcome // is heard where the asker of that seat listens. func TestABuildsEventsAreItsSeats(t *testing.T) { if BuildOutcomeOf(TheBuildMachineBefore) != "mesh.seat.mesh-build-machine.event.built" { t.Error(BuildOutcomeOf(TheBuildMachineBefore)) } if BuildWorkOf(TheBuildMachine) != BuildWork() || BuildOutcomeOf(TheBuildMachine) != BuildOutcome() || BuildStartedOf(TheBuildMachine) != BuildStarted() || BuildLogOf(TheBuildMachine, "b1") != BuildLog("b1") { t.Error("the no-argument forms must name the current role") } }