Skip to content

Commit

Permalink
Merge pull request #43 from njhale/chore/update-cred-overrides
Browse files Browse the repository at this point in the history
fix: use array and new pluralized name for credential overrides
  • Loading branch information
njhale authored Jul 1, 2024
2 parents 869ee34 + e1ccf96 commit a3474f4
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
30 changes: 30 additions & 0 deletions gptscript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,36 @@ func TestStreamRun(t *testing.T) {
}
}

func TestCredentialOverride(t *testing.T) {
wd, err := os.Getwd()
if err != nil {
t.Fatalf("Error getting working directory: %v", err)
}

run, err := g.Run(context.Background(), wd+"/test/credential-override.gpt", Options{
DisableCache: true,
CredentialOverrides: []string{
"test.ts.credential_override:TEST_CRED=foo",
},
})
if err != nil {
t.Fatalf("Error executing file: %v", err)
}

out, err := run.Text()
if err != nil {
t.Errorf("Error reading output: %v", err)
}

if !strings.Contains(out, "foo") {
t.Errorf("Unexpected output: %s", out)
}

if len(run.ErrorOutput()) != 0 {
t.Error("Should have no stderr output")
}
}

func TestParseSimpleFile(t *testing.T) {
wd, err := os.Getwd()
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ func (g GlobalOptions) toEnv() []string {
type Options struct {
GlobalOptions `json:",inline"`

Confirm bool `json:"confirm"`
Input string `json:"input"`
DisableCache bool `json:"disableCache"`
CacheDir string `json:"cacheDir"`
SubTool string `json:"subTool"`
Workspace string `json:"workspace"`
ChatState string `json:"chatState"`
IncludeEvents bool `json:"includeEvents"`
Prompt bool `json:"prompt"`
CredentialOverride string `json:"credentialOverride"`
Confirm bool `json:"confirm"`
Input string `json:"input"`
DisableCache bool `json:"disableCache"`
CacheDir string `json:"cacheDir"`
SubTool string `json:"subTool"`
Workspace string `json:"workspace"`
ChatState string `json:"chatState"`
IncludeEvents bool `json:"includeEvents"`
Prompt bool `json:"prompt"`
CredentialOverrides []string `json:"credentialOverrides"`
}
5 changes: 5 additions & 0 deletions test/credential-override.gpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
credentials: github.com/gptscript-ai/credential as test.ts.credential_override with TEST_CRED as env

#!/usr/bin/env bash

echo "${TEST_CRED}"

0 comments on commit a3474f4

Please sign in to comment.