diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-04-18 03:20:44 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-04-18 03:24:48 +0900 |
| commit | 9e752b588a66319c20a42dda761c43df5a5ad488 (patch) | |
| tree | a8c5829718a09683faaa0d59e3cd9095f18e9e28 /internal/pkg/pkg_test.go | |
| parent | 27b1aaae386578caadcdc2d34b7e1b5d78374efc (diff) | |
internal/pkg: drop cached error on cancel
This avoids disabling the artifact when using the individual cancel method. Unfortunately this makes the method blocking.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pkg/pkg_test.go')
| -rw-r--r-- | internal/pkg/pkg_test.go | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/internal/pkg/pkg_test.go b/internal/pkg/pkg_test.go index 3110ed06..f3011902 100644 --- a/internal/pkg/pkg_test.go +++ b/internal/pkg/pkg_test.go @@ -911,7 +911,7 @@ func TestCache(t *testing.T) { var started sync.WaitGroup defer started.Wait() - blockCures := func(d byte, n int) { + blockCures := func(d byte, e stub.UniqueError, n int) { started.Add(n) for i := range n { wg.Go(func() { @@ -920,9 +920,9 @@ func TestCache(t *testing.T) { cure: func(t *pkg.TContext) error { started.Done() <-t.Unwrap().Done() - return stub.UniqueError(0xbad0 + i) + return e + stub.UniqueError(i) }, - }}); !reflect.DeepEqual(err, stub.UniqueError(0xbad0+i)) { + }}); !reflect.DeepEqual(err, e+stub.UniqueError(i)) { panic(err) } }) @@ -930,15 +930,26 @@ func TestCache(t *testing.T) { started.Wait() } - blockCures(0xfd, 16) + blockCures(0xfd, 0xbad, 16) c.Abort() wg.Wait() - blockCures(0xff, 1) + blockCures(0xfd, 0xcafe, 16) + c.Abort() + wg.Wait() + + blockCures(0xff, 0xbad, 1) if !c.Cancel(unique.Make(pkg.ID{0xff})) { t.Fatal("missed cancellation") } wg.Wait() + + blockCures(0xff, 0xcafe, 1) + if !c.Cancel(unique.Make(pkg.ID{0xff})) { + t.Fatal("missed cancellation") + } + wg.Wait() + for c.Cancel(unique.Make(pkg.ID{0xff})) { } |
