execqueue_test.go 384 B

12345678910111213141516171819202122
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. package execqueue
  4. import (
  5. "context"
  6. "sync/atomic"
  7. "testing"
  8. )
  9. func TestExecQueue(t *testing.T) {
  10. ctx := context.Background()
  11. var n atomic.Int32
  12. q := &ExecQueue{}
  13. defer q.Shutdown()
  14. q.Add(func() { n.Add(1) })
  15. q.Wait(ctx)
  16. if got := n.Load(); got != 1 {
  17. t.Errorf("n=%d; want 1", got)
  18. }
  19. }