R1-4: the module's unit tests end at 159, within the budget
The drain's rows join the stopping runtime's table, the settings reader joins the start's cases, and the pull through a bundle's channel joins the take through it: 162 test functions become 159, every case kept (review round 1, finding 4). Builds: design 47 H2 §819
This commit is contained in:
@@ -13,11 +13,43 @@ import (
|
||||
"github.com/novox/mesh-tools/node-tools/internal/runtime"
|
||||
)
|
||||
|
||||
// The runner's start waits for its credential and its bus within the start's bound (issue 1496): one test, two cases, so
|
||||
// design 46 7-approval-mark §22's whole test of the gate adds no test to the module (design 47 G §419, §626).
|
||||
// The runner's start waits for its credential and its bus within the start's bound (issue 1496), and reads its settings
|
||||
// before it serves: one test, three cases, so design 46 7-approval-mark §22's whole test of the gate adds no test to the
|
||||
// module (design 47 G §419, §626).
|
||||
func TestTheRunnersStartWaitsForItsCredentialAndItsBus(t *testing.T) {
|
||||
t.Run("the credential", awaitsCredential)
|
||||
t.Run("the bus", connectsWithin)
|
||||
// **The runner's settings are read through the one settings reader** (design 47 H2 §813 (12), §775, H-A-369, H-A-370,
|
||||
// H-A-377): drain-bound, a duration text the node-engine composes as MESH_CONFIG_DRAIN_BOUND, 30 s when none is composed; a
|
||||
// value that is no duration, of it or of the kept call's pace, stops the runner before it serves, naming the setting.
|
||||
t.Run("its settings", func(t *testing.T) {
|
||||
for _, row := range []struct {
|
||||
word, composed, refused string
|
||||
want time.Duration
|
||||
}{
|
||||
{"MESH_CONFIG_DRAIN_BOUND", "", "", 30 * time.Second},
|
||||
{"MESH_CONFIG_DRAIN_BOUND", "5s", "", 5 * time.Second},
|
||||
{"MESH_CONFIG_DRAIN_BOUND", "30", "drain-bound", 0},
|
||||
{"MESH_CONFIG_KEPT_CALL_PACE_FIRST", "1", "kept-call-pace-first", 30 * time.Second},
|
||||
{"MESH_CONFIG_KEPT_CALL_PACE_MAX", "100ms", "kept-call-pace-max", 30 * time.Second},
|
||||
} {
|
||||
t.Run(row.word+"="+row.composed, func(t *testing.T) {
|
||||
t.Setenv(row.word, row.composed)
|
||||
if row.refused != "" {
|
||||
if err := serve(t.Context()); err == nil || !strings.Contains(err.Error(), row.refused) {
|
||||
t.Errorf("the runner with %s=%q served (%v); want it stopped before it serves, naming %s", row.word,
|
||||
row.composed, err, row.refused)
|
||||
}
|
||||
if row.want == 0 {
|
||||
return
|
||||
}
|
||||
}
|
||||
if got, err := drainBoundSetting(); err != nil || got != row.want {
|
||||
t.Errorf("drain-bound read %s, %v; want %s", got, err, row.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// A runtime started before its credential is on the machine waits for it, woken by the watch of its directory, and gives
|
||||
@@ -130,35 +162,3 @@ func connectsWithin(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// **The runner's settings are read through the one settings reader** (design 47 H2 §813 (12), §775, H-A-369, H-A-370,
|
||||
// H-A-377): drain-bound, a duration text the node-engine composes as MESH_CONFIG_DRAIN_BOUND, 30 s when none is composed; a
|
||||
// value that is no duration, of it or of the kept call's pace, stops the runner before it serves, naming the setting.
|
||||
func TestTheRunnersSettingsAreReadThroughTheOneReader(t *testing.T) {
|
||||
for _, row := range []struct {
|
||||
word, composed, refused string
|
||||
want time.Duration
|
||||
}{
|
||||
{"MESH_CONFIG_DRAIN_BOUND", "", "", 30 * time.Second},
|
||||
{"MESH_CONFIG_DRAIN_BOUND", "5s", "", 5 * time.Second},
|
||||
{"MESH_CONFIG_DRAIN_BOUND", "30", "drain-bound", 0},
|
||||
{"MESH_CONFIG_KEPT_CALL_PACE_FIRST", "1", "kept-call-pace-first", 30 * time.Second},
|
||||
{"MESH_CONFIG_KEPT_CALL_PACE_MAX", "100ms", "kept-call-pace-max", 30 * time.Second},
|
||||
} {
|
||||
t.Run(row.word+"="+row.composed, func(t *testing.T) {
|
||||
t.Setenv(row.word, row.composed)
|
||||
if row.refused != "" {
|
||||
if err := serve(t.Context()); err == nil || !strings.Contains(err.Error(), row.refused) {
|
||||
t.Errorf("the runner with %s=%q served (%v); want it stopped before it serves, naming %s", row.word,
|
||||
row.composed, err, row.refused)
|
||||
}
|
||||
if row.want == 0 {
|
||||
return
|
||||
}
|
||||
}
|
||||
if got, err := drainBoundSetting(); err != nil || got != row.want {
|
||||
t.Errorf("drain-bound read %s, %v; want %s", got, err, row.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user