Skip to content

Commit

Permalink
test(client): fix the priority of reading env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
northes committed Apr 2, 2024
1 parent 6aaa40a commit a947fd9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 9 additions & 1 deletion api_chat_completions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ func TestChatStream(t *testing.T) {
t.Error(err)
continue
}
t.Logf("Role: %s,Content: %s", msg.Role, msg.Content)

switch msg.Role {
case moonshot.RoleSystem:
case moonshot.RoleUser:
case moonshot.RoleAssistant:
default:
t.Logf("Role: %s,Content: %s", msg.Role, msg.Content)
}

}
}
11 changes: 7 additions & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ import (
)

func NewTestClient() (*moonshot.Client, error) {
err := godotenv.Load()
if err != nil {
panic(err)
}
key, ok := os.LookupEnv("MOONSHOT_KEY")
if !ok {
err := godotenv.Load()
if err != nil {
return nil, err
}
key, ok = os.LookupEnv("MOONSHOT_KEY")
}
if !ok {
return nil, errors.New("missing environment variable: MOONSHOT_KEY")
}
Expand Down

0 comments on commit a947fd9

Please sign in to comment.