Files
mesh-catalog/modules/distribution/cmd/distribution-tools/bounded_test.go
T
jschoubben c006538064 Distribution: the incoming-full finding is said off the publish's path
Builds: design 47 G (publish path of oci-artifact-registry; no design line covers it)
2026-11-15 01:38:27 +01:00

35 lines
1.1 KiB
Go

package main
import (
"strings"
"testing"
"time"
)
// A bus operation that never answers becomes an error naming its step, within the bound.
func TestAHungStepAnswersWithItsName(t *testing.T) {
block := make(chan struct{})
defer close(block)
_, err := step(10*time.Millisecond, "the write of the idle key", func() (int, error) { <-block; return 0, nil })
if err == nil || !strings.Contains(err.Error(), "the write of the idle key did not answer within") {
t.Fatalf("err = %v", err)
}
if v, err := step(time.Second, "x", func() (int, error) { return 7, nil }); v != 7 || err != nil {
t.Fatalf("%d %v", v, err)
}
}
// The finding is said off the caller's path: a writer that never answers does not hold the call that says it.
func TestAFindingIsSaidOffThePath(t *testing.T) {
block := make(chan struct{})
defer close(block)
say := boundedFinding(func(string, string, string, bool) { <-block })
done := make(chan struct{})
go func() { say("incoming-full", "incoming", "w", false); say("incoming-full", "incoming", "w", false); close(done) }()
select {
case <-done:
case <-time.After(5 * time.Second):
t.Fatal("the call was held by the finding")
}
}