MCPcopy
hub / github.com/minio/minio-go / TestGoexitDo

Function TestGoexitDo

pkg/singleflight/singleflight_test.go:257–287  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

255}
256
257func TestGoexitDo(t *testing.T) {
258 var g Group[string, any]
259 fn := func() (any, error) {
260 runtime.Goexit()
261 return nil, nil
262 }
263
264 const n = 5
265 waited := int32(n)
266 done := make(chan struct{})
267 for i := 0; i < n; i++ {
268 go func() {
269 var err error
270 defer func() {
271 if err != nil {
272 t.Errorf("Error should be nil, but got: %v", err)
273 }
274 if atomic.AddInt32(&waited, -1) == 0 {
275 close(done)
276 }
277 }()
278 _, err, _ = g.Do("key", fn)
279 }()
280 }
281
282 select {
283 case <-done:
284 case <-time.After(time.Second):
285 t.Fatalf("Do hangs")
286 }
287}
288
289func executable(t testing.TB) string {
290 exe, err := os.Executable()

Callers

nothing calls this directly

Calls 1

DoMethod · 0.80

Tested by

no test coverage detected