R1-F-sdk 1, 3: no test imports a seat's contract module, and the guard reads test imports
The import guard skipped _test.go files, so holdings_test.go's import of the mesh-broker seat would have reached mesh-sdk's go.mod at the pin (ADR 0625 §1, §3). The vault entries' comment says they stay to the next milestone (issue 1966 note 28). Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -3,8 +3,6 @@ package catalogue
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/seats/meshbroker"
|
||||
)
|
||||
|
||||
// **A seat's holder on record settles who holds it, and lets the next holder stand beside the
|
||||
@@ -20,9 +18,15 @@ func busSeatDelivering(t *testing.T, delivers string) {
|
||||
UseSeats([]Seat{{Name: "mesh-broker", Scope: ScopeMesh, Delivers: delivers, Decision: "test"}})
|
||||
}
|
||||
|
||||
// brokerVerbs are the bus seat's verbs as a literal: mesh-sdk imports no seat's contract module, a test neither
|
||||
// (ADR 0625 §3).
|
||||
func brokerVerbs() []string {
|
||||
return []string{"list", "show", "check", "orphans", "create", "apply", "recreate", "drop"}
|
||||
}
|
||||
|
||||
func newBroker() Manifest {
|
||||
return Manifest{Module: "new-broker", Provides: []Offer{{Name: "mesh-bus", Scope: ScopeMesh}},
|
||||
Claims: []Claim{{Name: "mesh-broker", Scope: ScopeMesh, Serves: meshbroker.Verbs()}}}
|
||||
Claims: []Claim{{Name: "mesh-broker", Scope: ScopeMesh, Serves: brokerVerbs()}}}
|
||||
}
|
||||
|
||||
// CanHold is the one judgement registration and the handover share, against the store's row.
|
||||
@@ -43,7 +47,7 @@ func TestCanHoldJudgesClaimScopeAndWhatTheSeatDelivers(t *testing.T) {
|
||||
t.Fatalf("a claim at the wrong scope was allowed: %v", err)
|
||||
}
|
||||
cannotAnswer := Manifest{Module: "amqp-only", Provides: []Offer{{Name: "amqp", Scope: ScopeMesh}},
|
||||
Claims: []Claim{{Name: "mesh-broker", Scope: ScopeMesh, Serves: meshbroker.Verbs()}}}
|
||||
Claims: []Claim{{Name: "mesh-broker", Scope: ScopeMesh, Serves: brokerVerbs()}}}
|
||||
if err := CanHold(cannotAnswer, seat); err == nil || !strings.Contains(err.Error(), `does not provide "mesh-bus"`) {
|
||||
t.Fatalf("a holder that cannot answer for the seat was allowed: %v", err)
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ var moduleWord = regexp.MustCompile(`\bmesh-(?:delivery|grants|vault|host|config
|
||||
var notInSDK = []string{"asks", "asker", "publish"}
|
||||
|
||||
// untilTheJoin is what ADR 0627 still moves at the group's join, each `<file>: <what>`, naming what the checks below
|
||||
// would refuse; it only shrinks, and is empty when the group is pinned: the vault module's name in delivery and
|
||||
// provisions goes when the vault's answers are its contract's.
|
||||
// would refuse; it only shrinks. The vault module's name in delivery and provisions stays past this milestone's pin
|
||||
// (issue 1966 note 28) and goes in the next milestone, when the vault's answers are its contract's.
|
||||
var untilTheJoin = []string{
|
||||
"delivery/signers.go: mesh-vault",
|
||||
"provisions/provisions.go: mesh-vault",
|
||||
@@ -96,7 +96,22 @@ func TestMeshSDKHoldsOnlyWhatEveryModuleShares(t *testing.T) {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") {
|
||||
if !strings.HasSuffix(path, ".go") {
|
||||
return nil
|
||||
}
|
||||
// A test's import is a requirement of mesh-sdk's go.mod too (ADR 0625 §1, §3): a test may import the seat set,
|
||||
// which catalogue already requires, and no other contracts module.
|
||||
if strings.HasSuffix(path, "_test.go") {
|
||||
file, err := parser.ParseFile(token.NewFileSet(), path, nil, parser.ImportsOnly)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, imp := range file.Imports {
|
||||
p, _ := strconv.Unquote(imp.Path.Value)
|
||||
if strings.HasPrefix(p, "git.novox.be/novox/mesh-contracts/") && p != contractsSeatSet {
|
||||
pending = append(pending, filepath.ToSlash(path)+": imports "+p)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
dir := filepath.ToSlash(filepath.Dir(path))
|
||||
|
||||
Reference in New Issue
Block a user