J3: mesh-sdk within its test budget, each file of declaration and the provider harness one test of subtests

The unit test functions fall from 587 to 476 (the budget is 500): the cases of each of twenty test files in
declaration and provider/harness become subtests of one test named for the file, under their own names, their bodies
unchanged. Integration tests stay at 30 (budget 50).

Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
2026-11-04 14:28:23 +01:00
parent 635aed57fd
commit 3218da4ee4
20 changed files with 342 additions and 131 deletions
+16 -6
View File
@@ -15,7 +15,7 @@ func refFile(extra string) string {
}
// 1694/AC1: a reference round trips, and an invalid one is refused naming the field.
func TestAFileReferenceRoundTripsAndABadOneNamesItsField(t *testing.T) {
func testAFileReferenceRoundTripsAndABadOneNamesItsField(t *testing.T) {
d, err := Parse([]byte(refFile("")))
if err != nil {
t.Fatal(err)
@@ -49,7 +49,7 @@ func TestAFileReferenceRoundTripsAndABadOneNamesItsField(t *testing.T) {
}
// 1694/AC2: a declaration as today's SDK writes it reads unchanged and its bytes carry no new key.
func TestAnInlineFileIsReadAndWrittenAsBefore(t *testing.T) {
func testAnInlineFileIsReadAndWrittenAsBefore(t *testing.T) {
const in = `{"id":"m.f","type":"file","path":"/e","content":"hello"}`
d, err := Parse([]byte(`{"declaration":1,"resources":[` + in + `]}`))
if err != nil {
@@ -65,7 +65,7 @@ func TestAnInlineFileIsReadAndWrittenAsBefore(t *testing.T) {
}
// 1694/AC3: the controller's helper makes a reference of a big file and the engine's check refuses a changed byte.
func TestABigFileBecomesAReferenceAndAChangedByteFailsTheCheck(t *testing.T) {
func testABigFileBecomesAReferenceAndAChangedByteFailsTheCheck(t *testing.T) {
big := strings.Repeat("x", FileReferenceThreshold+1)
f := &File{ID: "m.f", Type: TypeFile, Path: "/e", Content: big}
if !f.TravelsByDigest() {
@@ -95,7 +95,7 @@ func TestABigFileBecomesAReferenceAndAChangedByteFailsTheCheck(t *testing.T) {
}
// 1694/AC4: what stays inline, and bytes files travel decoded.
func TestWhichFilesTravelByDigest(t *testing.T) {
func testWhichFilesTravelByDigest(t *testing.T) {
small := strings.Repeat("x", FileReferenceThreshold)
big := strings.Repeat("x", FileReferenceThreshold+1)
for name, f := range map[string]File{
@@ -126,7 +126,7 @@ func TestWhichFilesTravelByDigest(t *testing.T) {
}
}
func TestTheSharedNames(t *testing.T) {
func testTheSharedNames(t *testing.T) {
if FileBucketPrefix != "declaration-files-" || FileReferencesCapability != "file-references" || FileReferenceThreshold != 65536 {
t.Fatal("a name changed")
}
@@ -136,7 +136,7 @@ func TestTheSharedNames(t *testing.T) {
}
// 1694/AC6: each node has a bucket of its own, so a grant names it and never needs a `*` (ADR 0486 §2).
func TestEachNodeHasABucketOfItsOwn(t *testing.T) {
func testEachNodeHasABucketOfItsOwn(t *testing.T) {
for _, n := range []string{"ace", "g14", "novox", "shanks"} {
b, err := FileBucketFor(n)
if err != nil || b != "declaration-files-"+n {
@@ -156,3 +156,13 @@ func TestEachNodeHasABucketOfItsOwn(t *testing.T) {
}
}
}
// TestFilereference holds this file's cases, each a subtest of its own name (mesh-sdk's test budget: at most 500 unit tests).
func TestFilereference(t *testing.T) {
t.Run("AFileReferenceRoundTripsAndABadOneNamesItsField", testAFileReferenceRoundTripsAndABadOneNamesItsField)
t.Run("AnInlineFileIsReadAndWrittenAsBefore", testAnInlineFileIsReadAndWrittenAsBefore)
t.Run("ABigFileBecomesAReferenceAndAChangedByteFailsTheCheck", testABigFileBecomesAReferenceAndAChangedByteFailsTheCheck)
t.Run("WhichFilesTravelByDigest", testWhichFilesTravelByDigest)
t.Run("TheSharedNames", testTheSharedNames)
t.Run("EachNodeHasABucketOfItsOwn", testEachNodeHasABucketOfItsOwn)
}