summaryrefslogtreecommitdiff
path: root/internal/model
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-07 00:03:30 +0300
committerPaul Buetow <paul@buetow.org>2026-05-07 00:03:30 +0300
commit973c3108b71063ea932aed6c67e16e393b5e6c41 (patch)
tree0fdfc73724b1478aa6993fc4ef2e6dd6c2e4cc19 /internal/model
parent1f162963c0950cdf08858940cf43e21e5741937d (diff)
task 81: replace test sleeps with deterministic sync
Diffstat (limited to 'internal/model')
-rw-r--r--internal/model/scan_test.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/internal/model/scan_test.go b/internal/model/scan_test.go
index cc0ba6b..acd1dd1 100644
--- a/internal/model/scan_test.go
+++ b/internal/model/scan_test.go
@@ -2,8 +2,8 @@ package model
import (
"errors"
+ "sync"
"testing"
- "time"
)
func TestScanProgress_Start(t *testing.T) {
@@ -116,8 +116,11 @@ func TestScanProgress_ConcurrentAccess(t *testing.T) {
p.Start(2)
p.SetFilesTotal(100)
+ start := make(chan struct{})
done := make(chan struct{})
+ var copies sync.WaitGroup
go func() {
+ <-start
for i := 0; i < 50; i++ {
p.IncrementFile()
}
@@ -125,9 +128,15 @@ func TestScanProgress_ConcurrentAccess(t *testing.T) {
}()
for i := 0; i < 50; i++ {
- _ = p.Copy()
- time.Sleep(time.Microsecond)
- }
+ copies.Add(1)
+ go func() {
+ defer copies.Done()
+ <-start
+ _ = p.Copy()
+ }()
+ }
+ close(start)
+ copies.Wait()
<-done
cp := p.Copy()