Skip to content

Commit e964fee

Browse files
committed
Synchronize transformed hook test inputs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ea968c1 commit e964fee

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

go/internal/e2e/hooks_extended_e2e_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,17 @@ func TestHooksExtendedE2E(t *testing.T) {
7676
t.Run("should invoke userPromptTransformed hook and modify transformed prompt", func(t *testing.T) {
7777
ctx.ConfigureForTest(t)
7878

79-
var inputs []copilot.UserPromptTransformedHookInput
79+
var (
80+
mu sync.Mutex
81+
inputs []copilot.UserPromptTransformedHookInput
82+
)
8083
session, err := client.CreateSession(t.Context(), &copilot.SessionConfig{
8184
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
8285
Hooks: &copilot.SessionHooks{
8386
OnUserPromptTransformed: func(input copilot.UserPromptTransformedHookInput, invocation copilot.HookInvocation) (*copilot.UserPromptTransformedHookOutput, error) {
87+
mu.Lock()
8488
inputs = append(inputs, input)
89+
mu.Unlock()
8590
if invocation.SessionID == "" {
8691
t.Error("Expected non-empty session ID in invocation")
8792
}
@@ -99,6 +104,9 @@ func TestHooksExtendedE2E(t *testing.T) {
99104
if err != nil {
100105
t.Fatalf("Failed to send message: %v", err)
101106
}
107+
108+
mu.Lock()
109+
defer mu.Unlock()
102110
if len(inputs) == 0 {
103111
t.Fatal("Expected at least one userPromptTransformed hook invocation")
104112
}

0 commit comments

Comments
 (0)