Skip to content

Commit 41e34d8

Browse files
committed
fix: resolve race condition in research agent test
1 parent 6836276 commit 41e34d8

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

engine/research_agent_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"errors"
66
"fmt"
77
"strings"
8+
"sync"
89
"sync/atomic"
910
"testing"
1011
"time"
@@ -422,9 +423,12 @@ func TestResearch(t *testing.T) {
422423
ra := NewResearchAgent(2)
423424
ra.Timeout = 5 * time.Second
424425

426+
var mu sync.Mutex
425427
var searched []string
426428
searchFn := func(q string) (string, error) {
429+
mu.Lock()
427430
searched = append(searched, q)
431+
mu.Unlock()
428432
return "result for " + q, nil
429433
}
430434

0 commit comments

Comments
 (0)