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.
69 lines
2.9 KiB
Go
69 lines
2.9 KiB
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
"github.com/novox/mesh-controller/internal/inventory"
|
|
"github.com/novox/mesh-controller/internal/link"
|
|
)
|
|
|
|
// A member of a group whose gate is the composed check's is asked of the build seat with no module: its repository's
|
|
// check alone (novox/hq ADR 0403 clause 1). With no word from mesh-delivery, or one that does not say the gate is
|
|
// composed, it is checked alone with its gate (clause 6).
|
|
|
|
func askedForMember(t *testing.T, answer []groupsLine, answerErr error) link.CheckRequest {
|
|
t.Helper()
|
|
open := aMesh(t)
|
|
ctx := t.Context()
|
|
js, _ := aBuildQueue(t)
|
|
servingBus.Store(js)
|
|
t.Cleanup(func() { servingBus.Store(nil) })
|
|
if err := open.inventory.RegisterModule(ctx, catalogue.Manifest{Module: "mesh-controller", Version: "1"},
|
|
inventory.Source{Repository: "novox/mesh-controller", Ref: "main", BuiltFrom: "c0", Head: "c0"}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
was := groupsAsked
|
|
groupsAsked = func(context.Context, bool) ([]groupsLine, error) { return answer, answerErr }
|
|
t.Cleanup(func() { groupsAsked = was })
|
|
p := link.PullUpdated{Owner: "novox", Repo: "mesh-controller", Number: 346, Base: "main", Head: "feat/x", Commit: headController,
|
|
Paths: []string{"main.go"}, ModuleDirsSaid: true, MergeCheck: true, MergeCheckSaid: true}
|
|
if err := (following{open: open, oneShot: true}).PullUpdated(ctx, p); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
q, err := link.ReadQueue(ctx, js, link.TheBuildMachine)
|
|
if err != nil || len(q.Asks) != 1 {
|
|
t.Fatalf("asks %d: %v", len(q.Asks), err)
|
|
}
|
|
return *q.Asks[0].Request.Check
|
|
}
|
|
|
|
func TestAComposedMembersCheckIsItsRepositoryChecksAlone(t *testing.T) {
|
|
line := group("feat/x", member("novox/mesh-controller", 346, headController, "main", true), member("novox/mesh-catalog", 350, headHost, "main", true))
|
|
line.ComposedGate = true
|
|
c := askedForMember(t, []groupsLine{line}, nil)
|
|
if len(c.Modules) != 0 || len(c.New) != 0 || len(c.Dependents) != 0 || !c.Composed {
|
|
t.Fatalf("the member's check is asked as %+v; want no module and composed", c)
|
|
}
|
|
}
|
|
|
|
func TestAMemberOfAGroupOfAnOlderMeshDeliveryKeepsItsOwnGate(t *testing.T) {
|
|
line := group("feat/x", member("novox/mesh-controller", 346, headController, "main", true), member("novox/mesh-catalog", 350, headHost, "main", true))
|
|
c := askedForMember(t, []groupsLine{line}, nil)
|
|
if !strings.Contains(strings.Join(c.Modules, ","), "mesh-controller") || c.Composed {
|
|
t.Fatalf("an older mesh-delivery's member is asked as %+v; want its own gate", c)
|
|
}
|
|
}
|
|
|
|
func TestAMemberWhoseGroupCannotBeLearnedIsCheckedAloneWithItsGate(t *testing.T) {
|
|
c := askedForMember(t, nil, context.DeadlineExceeded)
|
|
if !strings.Contains(strings.Join(c.Modules, ","), "mesh-controller") || c.Composed ||
|
|
!strings.Contains(c.SiblingsUnknown, "reads no siblings") {
|
|
t.Fatalf("the member is asked as %+v; want its gate and why its siblings are unknown", c)
|
|
}
|
|
}
|