mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-02 06:19:34 +08:00
Merge branch 'master' into bugfix/huangbin/ai_service
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
//go:build localtest
|
||||
|
||||
package ai
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httprunner/v5/internal/builtin"
|
||||
@@ -11,24 +12,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// hasRequiredEnvVars checks if the required environment variables are set for testing
|
||||
func hasRequiredEnvVars() bool {
|
||||
// Check for OpenAI environment variables
|
||||
if os.Getenv("OPENAI_BASE_URL") != "" && os.Getenv("OPENAI_API_KEY") != "" {
|
||||
return true
|
||||
}
|
||||
// Check for GPT-4O specific environment variables
|
||||
if os.Getenv("OPENAI_GPT_4O_BASE_URL") != "" && os.Getenv("OPENAI_GPT_4O_API_KEY") != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func TestILLMServiceQuery(t *testing.T) {
|
||||
// Skip test if required environment variables are not set
|
||||
if !hasRequiredEnvVars() {
|
||||
t.Skip("Skipping test: required environment variables not set")
|
||||
}
|
||||
|
||||
// Create LLM service
|
||||
service, err := NewLLMService(option.OPENAI_GPT_4O)
|
||||
@@ -96,10 +80,6 @@ func TestILLMServiceQuery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestILLMServiceIntegration(t *testing.T) {
|
||||
// Skip test if required environment variables are not set
|
||||
if !hasRequiredEnvVars() {
|
||||
t.Skip("Skipping test: required environment variables not set")
|
||||
}
|
||||
|
||||
// Create LLM service
|
||||
service, err := NewLLMService(option.OPENAI_GPT_4O)
|
||||
|
||||
Reference in New Issue
Block a user