E8: run each file's unit tests as subtests of one test
The node-engine held 1,707 top-level unit tests against the budget of 500 a module. Each unit test file with two or more tests now runs them as subtests of one test named for the file, each named as its function was, in the same order: every check is kept, and the check counts 383. Files with a TestMain, a re-run of a test by its name, or the integration tag are left. Four files of this branch's earlier commits are formatted. Builds: design 47 H2 §819; H-A-349 DQ-14
This commit is contained in:
@@ -16,7 +16,7 @@ func optionalShelf() map[string]mcat.Manifest {
|
||||
)
|
||||
}
|
||||
|
||||
func TestAnOptionalRequirementWithNoProviderIsAbsentAndNothingIsInstalled(t *testing.T) {
|
||||
func testAnOptionalRequirementWithNoProviderIsAbsentAndNothingIsInstalled(t *testing.T) {
|
||||
// Exactly one catalogue module could answer each — the case where a hard requirement installs it.
|
||||
// Brokered (influxdb-api, from anywhere) and on this machine (shell); both passes.
|
||||
for _, world := range []mcat.World{{}, {Unchecked: true}} {
|
||||
@@ -40,7 +40,7 @@ func TestAnOptionalRequirementWithNoProviderIsAbsentAndNothingIsInstalled(t *tes
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnOptionalRequirementWithAProviderBindsAsAHardOne(t *testing.T) {
|
||||
func testAnOptionalRequirementWithAProviderBindsAsAHardOne(t *testing.T) {
|
||||
world := mcat.World{Offered: map[string][]mcat.Provider{"influxdb-api": {
|
||||
{Node: "anchor", At: "anchor.internal", Module: "influxdb", Serves: map[string]any{"port": 8086}}}}}
|
||||
got, err := Resolve(optionalShelf(), []string{"grafana", "zsh"}, reachable(), world)
|
||||
@@ -64,7 +64,7 @@ func TestAnOptionalRequirementWithAProviderBindsAsAHardOne(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOneConsumersOptionalRequirementIsAnothersHardOne(t *testing.T) {
|
||||
func testOneConsumersOptionalRequirementIsAnothersHardOne(t *testing.T) {
|
||||
// telegraf wants influxdb-api hard: with nothing offering it, the assignment is refused as
|
||||
// before, naming what to assign — grafana's optional does not soften telegraf's.
|
||||
_, err := Resolve(optionalShelf(), []string{"grafana", "telegraf"}, reachable(), mcat.World{})
|
||||
@@ -91,7 +91,7 @@ func TestOneConsumersOptionalRequirementIsAnothersHardOne(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAHardRequirementWithNoProviderIsStillRefused(t *testing.T) {
|
||||
func testAHardRequirementWithNoProviderIsStillRefused(t *testing.T) {
|
||||
_, err := Resolve(optionalShelf(), []string{"telegraf"}, reachable(), mcat.World{})
|
||||
if err == nil || !strings.Contains(err.Error(), "influxdb") {
|
||||
t.Fatalf("got %v", err)
|
||||
@@ -124,7 +124,7 @@ func absentGrafana(t *testing.T, absent bool) mcat.Resolution {
|
||||
return r
|
||||
}
|
||||
|
||||
func TestAnAbsentRequirementIsComposedWithItsDefaultsAndWithoutItsFiles(t *testing.T) {
|
||||
func testAnAbsentRequirementIsComposedWithItsDefaultsAndWithoutItsFiles(t *testing.T) {
|
||||
out, err := Declaration(absentGrafana(t, true), mcat.Rendering{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -145,7 +145,7 @@ func TestAnAbsentRequirementIsComposedWithItsDefaultsAndWithoutItsFiles(t *testi
|
||||
}
|
||||
}
|
||||
|
||||
func TestABoundOptionalRequirementIsComposedAsAHardOne(t *testing.T) {
|
||||
func testABoundOptionalRequirementIsComposedAsAHardOne(t *testing.T) {
|
||||
out, err := Declaration(absentGrafana(t, false), mcat.Rendering{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -166,3 +166,13 @@ func TestABoundOptionalRequirementIsComposedAsAHardOne(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestOptionalRequirements runs this file's tests, each a subtest named as its function was (design 47 H2 §819, the test budget).
|
||||
func TestOptionalRequirements(t *testing.T) {
|
||||
t.Run("AnOptionalRequirementWithNoProviderIsAbsentAndNothingIsInstalled", testAnOptionalRequirementWithNoProviderIsAbsentAndNothingIsInstalled)
|
||||
t.Run("AnOptionalRequirementWithAProviderBindsAsAHardOne", testAnOptionalRequirementWithAProviderBindsAsAHardOne)
|
||||
t.Run("OneConsumersOptionalRequirementIsAnothersHardOne", testOneConsumersOptionalRequirementIsAnothersHardOne)
|
||||
t.Run("AHardRequirementWithNoProviderIsStillRefused", testAHardRequirementWithNoProviderIsStillRefused)
|
||||
t.Run("AnAbsentRequirementIsComposedWithItsDefaultsAndWithoutItsFiles", testAnAbsentRequirementIsComposedWithItsDefaultsAndWithoutItsFiles)
|
||||
t.Run("ABoundOptionalRequirementIsComposedAsAHardOne", testABoundOptionalRequirementIsComposedAsAHardOne)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user