1package sync23import (4 "context"5 "strconv"6 "sync"7 "testing"8)910func TestWorkPool(t *testing.T) {11 mtx := &sync.Mutex{}12 values := make([]int, 0)13 wp := NewWorkPool(context.Background(), 3)14 for i := 0; i < 10; i++ {15 id := strconv.Itoa(i)16 i := i17 wp.Add(id, func() {18 mtx.Lock()19 values = append(values, i)20 mtx.Unlock()21 })22 }23 wp.Run()2425 if len(values) != 10 {26 t.Errorf("expected 10 values, got %d, %v", len(values), values)27 }2829 for i := range values {30 id := strconv.Itoa(i)31 if wp.Status(id) {32 t.Errorf("expected %s to be false", id)33 }34 }35}