mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-16 18:41:03 +01:00
Add basic sanity test to confirm that our interactions with the OpenAI API are correct
This commit is contained in:
parent
a8f47cf340
commit
1a450c0817
1
.github/workflows/go-test.yml
vendored
1
.github/workflows/go-test.yml
vendored
@ -66,6 +66,7 @@ jobs:
|
|||||||
- name: Go test
|
- name: Go test
|
||||||
env:
|
env:
|
||||||
DD_API_KEY: ${{ secrets.DD_API_KEY }}
|
DD_API_KEY: ${{ secrets.DD_API_KEY }}
|
||||||
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
run: |
|
run: |
|
||||||
|
|
||||||
# Once https://github.com/gotestyourself/gotestsum/pull/377 is merged, update this to pull from main rather than my fork
|
# Once https://github.com/gotestyourself/gotestsum/pull/377 is merged, update this to pull from main rather than my fork
|
||||||
|
25
shared/ai/ai_test.go
Normal file
25
shared/ai/ai_test.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package ai
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
// A basic sanity test that our integration with the OpenAI API is correct and is returning reasonable results (at least for a very basic query)
|
||||||
|
func TestLiveOpenAiApi(t *testing.T) {
|
||||||
|
if os.Getenv("OPENAI_API_KEY") == "" {
|
||||||
|
t.Skip("Skipping test since OPENAI_API_KEY is not set")
|
||||||
|
}
|
||||||
|
results, _, err := GetAiSuggestionsViaOpenAiApi("list files in the current directory", 3)
|
||||||
|
require.NoError(t, err)
|
||||||
|
resultsContainsLs := false
|
||||||
|
for _, result := range results {
|
||||||
|
if strings.Contains(result, "ls") {
|
||||||
|
resultsContainsLs = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
require.Truef(t, resultsContainsLs, "expected results=%#v to contain ls", results)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user