The three tests of the controller's own module.json (process, claimed seat, addresses), the Dockerfile and Makefile pin test, the build-agent registry test and the manifest-in-use seat test move with their old package, as tests of mesh-sdk's exported API; a moved test is exempt from failing first.
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
package inventory
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
"github.com/novox/mesh-controller/internal/broker"
|
|
)
|
|
|
|
// novox/hq issue 218: a seat held once for the mesh is granted and issued only to the holder on record;
|
|
// a node seat to every machine's claimant; a mesh seat with no holder on record as derived.
|
|
func TestOnlyTheRecordedHolderHoldsAMeshSeat(t *testing.T) {
|
|
claimed := []broker.Seat{
|
|
{Name: "mesh-store", Scope: catalogue.ScopeMesh},
|
|
{Name: "node-packet-filter", Scope: catalogue.ScopeNode},
|
|
{Name: "unrecorded", Scope: catalogue.ScopeMesh},
|
|
}
|
|
holdings := []catalogue.Held{{Claim: "mesh-store", Scope: catalogue.ScopeMesh, Node: "control", Module: "postgres"}}
|
|
names := func(ss []broker.Seat) (out []string) {
|
|
for _, s := range ss {
|
|
out = append(out, s.Name)
|
|
}
|
|
return
|
|
}
|
|
if got := names(heldHere(claimed, holdings, "control", "postgres")); len(got) != 3 {
|
|
t.Errorf("the holder lost a seat: %v", got)
|
|
}
|
|
got := names(heldHere(claimed, holdings, "other", "postgres"))
|
|
if len(got) != 2 || got[0] != "node-packet-filter" || got[1] != "unrecorded" {
|
|
t.Errorf("a claimant on another machine holds %v; want the node seat and the unrecorded one, not the store", got)
|
|
}
|
|
}
|