Skip to content

Commit ca198d8

Browse files
committed
fix: adjust TestConfirm for Windows
This change also contains a fix to avoid building the cred store binary when running the windows tests. Signed-off-by: Donnie Adams <[email protected]>
1 parent 39e4e76 commit ca198d8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

gptscript_test.go

+16-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestMain(m *testing.M) {
2020
}
2121

2222
var err error
23-
g, err = NewGPTScript(GlobalOptions{})
23+
g, err = NewGPTScript(GlobalOptions{OpenAIAPIKey: os.Getenv("OPENAI_API_KEY")})
2424
if err != nil {
2525
panic(fmt.Sprintf("error creating gptscript: %s", err))
2626
}
@@ -734,6 +734,20 @@ func TestConfirm(t *testing.T) {
734734
for _, o := range e.Call.Output {
735735
eventContent += o.Content
736736
}
737+
738+
if e.Call.Type == EventTypeCallConfirm {
739+
// On Windows, ls may not be recognized as a command. The LLM will try to run the dir command. Confirm it.
740+
if !strings.Contains(e.Call.Input, "\"dir\"") {
741+
t.Errorf("unexpected confirm input: %s", e.Call.Input)
742+
}
743+
744+
if err = g.Confirm(context.Background(), AuthResponse{
745+
ID: e.Call.ID,
746+
Accept: true,
747+
}); err != nil {
748+
t.Errorf("Error confirming: %v", err)
749+
}
750+
}
737751
}
738752
}
739753

@@ -742,7 +756,7 @@ func TestConfirm(t *testing.T) {
742756
t.Errorf("Error reading output: %v", err)
743757
}
744758

745-
if !strings.Contains(eventContent, "Makefile\nREADME.md") {
759+
if !strings.Contains(eventContent, "Makefile") || !strings.Contains(eventContent, "README.md") {
746760
t.Errorf("Unexpected event output: %s", eventContent)
747761
}
748762

0 commit comments

Comments
 (0)