Prepare verified laboratory 7 implementation and evidence

This commit is contained in:
rey
2026-11-17 17:32:06 +03:00
parent 20afc2c790
commit eb1b5c7b84
677 changed files with 208256 additions and 64 deletions
@@ -0,0 +1,37 @@
package lifecycle
import (
"context"
"errors"
"testing"
)
func TestMonitorStopsNormalWorkOnceOnFreshnessFailure(t *testing.T) {
stops, reports := 0, 0
r, e := New(Ports{Watch: func(context.Context) error { return errors.New("expired") }, Stop: func() { stops++ }, Report: func() { reports++ }})
if e != nil {
t.Fatal(e)
}
r.Run(context.Background())
if stops != 1 || reports != 1 {
t.Fatal("freshness failure did not stop normal work")
}
}
func TestMonitorDoesNotReportNormalCancellation(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
stops := 0
r, e := New(Ports{Watch: func(context.Context) error { return context.Canceled }, Stop: func() { stops++ }, Report: func() { t.Fatal("normal stop reported failure") }})
if e != nil {
t.Fatal(e)
}
r.Run(ctx)
if stops != 0 {
t.Fatal("normal cancellation invoked failure stop")
}
}
func TestMonitorRejectsMissingPorts(t *testing.T) {
if _, e := New(Ports{}); e == nil {
t.Fatal("process monitor accepted implicit production ports")
}
}