Skip to content

Commit 114eb11

Browse files
committed
fixes
Signed-off-by: Grant Linville <[email protected]>
1 parent 1c0e3ec commit 114eb11

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

gptscript.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,16 @@ func (g *GPTScript) PromptResponse(ctx context.Context, resp PromptResponse) err
308308
}
309309

310310
type ListCredentialsOptions struct {
311-
credCtxs []string
312-
allContexts bool
311+
CredentialContexts []string
312+
AllContexts bool
313313
}
314314

315315
func (g *GPTScript) ListCredentials(ctx context.Context, opts ListCredentialsOptions) ([]Credential, error) {
316316
req := CredentialRequest{}
317-
if opts.allContexts {
317+
if opts.AllContexts {
318318
req.AllContexts = true
319-
} else if len(opts.credCtxs) > 0 {
320-
req.Context = opts.credCtxs
319+
} else if len(opts.CredentialContexts) > 0 {
320+
req.Context = opts.CredentialContexts
321321
} else {
322322
req.Context = []string{"default"}
323323
}

gptscript_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ func TestCredentials(t *testing.T) {
14721472

14731473
// List
14741474
creds, err := g.ListCredentials(context.Background(), ListCredentialsOptions{
1475-
credCtxs: []string{"testing"},
1475+
CredentialContexts: []string{"testing"},
14761476
})
14771477
require.NoError(t, err)
14781478
require.GreaterOrEqual(t, len(creds), 1)

run_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/rand"
66
"encoding/hex"
7+
"os"
78
"runtime"
89
"testing"
910

@@ -50,14 +51,17 @@ func TestRestartingErrorRun(t *testing.T) {
5051
func TestStackedContexts(t *testing.T) {
5152
const name = "testcred"
5253

54+
wd, err := os.Getwd()
55+
require.NoError(t, err)
56+
5357
bytes := make([]byte, 32)
54-
_, err := rand.Read(bytes)
58+
_, err = rand.Read(bytes)
5559
require.NoError(t, err)
5660

5761
context1 := hex.EncodeToString(bytes)[:16]
5862
context2 := hex.EncodeToString(bytes)[16:]
5963

60-
run, err := g.Run(context.Background(), "test/credential.gpt", Options{
64+
run, err := g.Run(context.Background(), wd+"/test/credential.gpt", Options{
6165
CredentialContexts: []string{context1, context2},
6266
})
6367
require.NoError(t, err)
@@ -71,7 +75,7 @@ func TestStackedContexts(t *testing.T) {
7175
require.Equal(t, cred.Context, context1)
7276

7377
// Now change the context order and run the script again.
74-
run, err = g.Run(context.Background(), "test/credential.gpt", Options{
78+
run, err = g.Run(context.Background(), wd+"/test/credential.gpt", Options{
7579
CredentialContexts: []string{context2, context1},
7680
})
7781
require.NoError(t, err)

0 commit comments

Comments
 (0)