Skip to content

🎧 Your Personal Streaming Service

Make tests compatible with GoLang 1.18

Deluandc16ccdb93c1
diff --git a/utils/pl/pipelines_test.go b/utils/pl/pipelines_test.go
index f5da6e49f..39e7d0142 100644
--- a/utils/pl/pipelines_test.go
+++ b/utils/pl/pipelines_test.go
@@ -53,15 +53,13 @@ var _ = Describe("Pipeline", func() {
}
close(inC)
- current := atomic.Int32{}
- count := atomic.Int32{}
- max := atomic.Int32{}
+ var current, count, max int32
outC, _ := pl.Stage(context.Background(), maxWorkers, inC, func(ctx context.Context, in int) (int, error) {
- defer current.Add(-1)
- c := current.Add(1)
- count.Add(1)
- if c > max.Load() {
- max.Store(c)
+ defer atomic.AddInt32(&current, -1)
+ c := atomic.AddInt32(&current, 1)
+ atomic.AddInt32(&count, 1)
+ if c > atomic.LoadInt32(&max) {
+ atomic.StoreInt32(&max, c)
}
time.Sleep(10 * time.Millisecond) // Slow process
return 0, nil
@@ -70,9 +68,9 @@ var _ = Describe("Pipeline", func() {
for range outC {
}
- Expect(count.Load()).To(Equal(int32(numJobs)))
- Expect(current.Load()).To(Equal(int32(0)))
- Expect(max.Load()).To(Equal(int32(maxWorkers)))
+ Expect(count).To(Equal(int32(numJobs)))
+ Expect(current).To(Equal(int32(0)))
+ Expect(max).To(Equal(int32(maxWorkers)))
})
})
When("the context is canceled", func() {