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:
@@ -16,7 +16,7 @@ const adoptedResources = `"resources":[
|
||||
|
||||
const sixtyFour = "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
|
||||
func TestAnAdoptionIsReadWithTheDeclaration(t *testing.T) {
|
||||
func testAnAdoptionIsReadWithTheDeclaration(t *testing.T) {
|
||||
d, err := Parse([]byte(`{"adoption":{"taken":["postgres"],"untaken":{"hello-web":["hello-web.page","hello-web.server"]}},
|
||||
"declaration":1,` + adoptedResources + `}`))
|
||||
if err != nil {
|
||||
@@ -36,7 +36,7 @@ func TestAnAdoptionIsReadWithTheDeclaration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestADeclarationWithNoAdoptionIsConverged(t *testing.T) {
|
||||
func testADeclarationWithNoAdoptionIsConverged(t *testing.T) {
|
||||
d, err := Parse([]byte(`{"declaration":1,` + adoptedResources + `}`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -49,7 +49,7 @@ func TestADeclarationWithNoAdoptionIsConverged(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnAdoptionNamingAnUnknownIDIsRefused(t *testing.T) {
|
||||
func testAnAdoptionNamingAnUnknownIDIsRefused(t *testing.T) {
|
||||
refusal := refusalFor(t, `{"adoption":{"taken":[],"untaken":{"hello-web":["hello-web.missing"]}},
|
||||
"declaration":1,`+adoptedResources+`}`)
|
||||
if !strings.Contains(strings.Join(refusal.Problems, "\n"), "hello-web.missing") {
|
||||
@@ -57,7 +57,7 @@ func TestAnAdoptionNamingAnUnknownIDIsRefused(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnAdoptionMayNameAResourceOfAnyKind(t *testing.T) {
|
||||
func testAnAdoptionMayNameAResourceOfAnyKind(t *testing.T) {
|
||||
// A directory, a service or an action can reach what was found as surely as a file can, so
|
||||
// the controller lists every resource of an untaken module (novox/hq ADR 0103).
|
||||
d, err := Parse([]byte(`{"adoption":{"taken":[],"untaken":{"hello-web":["hello-web.data"]}},
|
||||
@@ -70,7 +70,7 @@ func TestAnAdoptionMayNameAResourceOfAnyKind(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnIDUnderTwoModulesIsRefused(t *testing.T) {
|
||||
func testAnIDUnderTwoModulesIsRefused(t *testing.T) {
|
||||
refusal := refusalFor(t, `{"adoption":{"taken":[],"untaken":{"a":["hello-web.page"],"b":["hello-web.page"]}},
|
||||
"declaration":1,`+adoptedResources+`}`)
|
||||
if !strings.Contains(strings.Join(refusal.Problems, "\n"), "both") {
|
||||
@@ -78,7 +78,7 @@ func TestAnIDUnderTwoModulesIsRefused(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAModuleBothTakenAndUntakenIsRefused(t *testing.T) {
|
||||
func testAModuleBothTakenAndUntakenIsRefused(t *testing.T) {
|
||||
refusal := refusalFor(t, `{"adoption":{"taken":["hello-web"],"untaken":{"hello-web":["hello-web.page"]}},
|
||||
"declaration":1,`+adoptedResources+`}`)
|
||||
if !strings.Contains(strings.Join(refusal.Problems, "\n"), "both taken and untaken") {
|
||||
@@ -86,7 +86,7 @@ func TestAModuleBothTakenAndUntakenIsRefused(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestTheMeshsOwnResourcesAreNeverUntaken(t *testing.T) {
|
||||
func testTheMeshsOwnResourcesAreNeverUntaken(t *testing.T) {
|
||||
refusal := refusalFor(t, `{"adoption":{"taken":[],"untaken":{"x":["adoption.guard"]}},
|
||||
"declaration":1,"resources":[
|
||||
{"id":"adoption.guard","type":"file","path":"/etc/mesh/guard.nft","content":"x"}]}`)
|
||||
@@ -95,11 +95,11 @@ func TestTheMeshsOwnResourcesAreNeverUntaken(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnAdoptionWithAnUnknownFieldIsRefused(t *testing.T) {
|
||||
func testAnAdoptionWithAnUnknownFieldIsRefused(t *testing.T) {
|
||||
refusalFor(t, `{"adoption":{"taken":[],"held":["x"]},"declaration":1,`+adoptedResources+`}`)
|
||||
}
|
||||
|
||||
func TestACarriedBundleCannotSayTheNodeIsAdopted(t *testing.T) {
|
||||
func testACarriedBundleCannotSayTheNodeIsAdopted(t *testing.T) {
|
||||
_, err := ParseTrusted([]byte(`{"adoption":{"taken":[]},"declaration":1,` + adoptedResources + `}`))
|
||||
if err == nil || !strings.Contains(err.Error(), "only the mesh can say") {
|
||||
t.Fatalf("a bundle claiming adoption was not refused: %v", err)
|
||||
@@ -107,7 +107,7 @@ func TestACarriedBundleCannotSayTheNodeIsAdopted(t *testing.T) {
|
||||
}
|
||||
|
||||
// novox/hq ADR 0105: a service may take over a found tunnel, said whole and on an adopted node.
|
||||
func TestTakingOverATunnelIsSaidWholeAndForARunningService(t *testing.T) {
|
||||
func testTakingOverATunnelIsSaidWholeAndForARunningService(t *testing.T) {
|
||||
adoptedWith := func(service string) error {
|
||||
_, err := Parse([]byte(`{"declaration":1,"adoption":{"taken":[]},"resources":[` + service + `]}`))
|
||||
return err
|
||||
@@ -130,3 +130,17 @@ func TestTakingOverATunnelIsSaidWholeAndForARunningService(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestAdoption holds this file's cases, each a subtest of its own name (mesh-sdk's test budget: at most 500 unit tests).
|
||||
func TestAdoption(t *testing.T) {
|
||||
t.Run("AnAdoptionIsReadWithTheDeclaration", testAnAdoptionIsReadWithTheDeclaration)
|
||||
t.Run("ADeclarationWithNoAdoptionIsConverged", testADeclarationWithNoAdoptionIsConverged)
|
||||
t.Run("AnAdoptionNamingAnUnknownIDIsRefused", testAnAdoptionNamingAnUnknownIDIsRefused)
|
||||
t.Run("AnAdoptionMayNameAResourceOfAnyKind", testAnAdoptionMayNameAResourceOfAnyKind)
|
||||
t.Run("AnIDUnderTwoModulesIsRefused", testAnIDUnderTwoModulesIsRefused)
|
||||
t.Run("AModuleBothTakenAndUntakenIsRefused", testAModuleBothTakenAndUntakenIsRefused)
|
||||
t.Run("TheMeshsOwnResourcesAreNeverUntaken", testTheMeshsOwnResourcesAreNeverUntaken)
|
||||
t.Run("AnAdoptionWithAnUnknownFieldIsRefused", testAnAdoptionWithAnUnknownFieldIsRefused)
|
||||
t.Run("ACarriedBundleCannotSayTheNodeIsAdopted", testACarriedBundleCannotSayTheNodeIsAdopted)
|
||||
t.Run("TakingOverATunnelIsSaidWholeAndForARunningService", testTakingOverATunnelIsSaidWholeAndForARunningService)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user