mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-24 01:40:02 +08:00
fix: convert AI tests from skip statements to build tags (#1783)
* fix: convert AI tests from skip statements to build tags - Add //go:build localtest tag to uixt/ai/ai_test.go and examples/game/llk/main_test.go - Remove environment-based skip statements and hasRequiredEnvVars functions - Maintain consistency with existing build tag approach for mobile/device tests - Prevents CI/CD failures when external AI services are not available Co-authored-by: debugtalk <debugtalk@users.noreply.github.com> * fix: add missing BoundBox type and field to Element struct - Add BoundBox struct with X, Y, Width, Height fields - Update Element struct to include BoundBox field - Fix structural mismatch between test expectations and Go code - Resolves CI compilation failures Co-authored-by: debugtalk <debugtalk@users.noreply.github.com> --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
This commit is contained in:
@@ -34,6 +34,15 @@ type Dimensions struct {
|
||||
type Element struct {
|
||||
Type string `json:"type"` // Element type/name
|
||||
Position Position `json:"position"` // Position in grid
|
||||
BoundBox BoundBox `json:"boundBox"` // Bounding box coordinates
|
||||
}
|
||||
|
||||
// BoundBox represents bounding box coordinates
|
||||
type BoundBox struct {
|
||||
X float64 `json:"x"` // X coordinate
|
||||
Y float64 `json:"y"` // Y coordinate
|
||||
Width float64 `json:"width"` // Box width
|
||||
Height float64 `json:"height"` // Box height
|
||||
}
|
||||
|
||||
// Position represents grid position
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
//go:build localtest
|
||||
|
||||
package llk
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -97,18 +98,6 @@ func convertToGameElementFromQueryResult(result *ai.QueryResult) (*GameElement,
|
||||
return &gameElement, nil
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// loadTestImage loads the test image from testdata
|
||||
func loadTestImage(t *testing.T) (string, types.Size) {
|
||||
@@ -129,9 +118,6 @@ func createAIQueryer(t *testing.T) *ai.Querier {
|
||||
|
||||
// TestLLKGameBot_AnalyzeGameInterface comprehensive test for game interface analysis
|
||||
func TestLLKGameBot_AnalyzeGameInterface(t *testing.T) {
|
||||
if !hasRequiredEnvVars() {
|
||||
t.Skip("Skipping test: required environment variables not set")
|
||||
}
|
||||
|
||||
t.Run("AnalyzeWithTestImage", func(t *testing.T) {
|
||||
// Create test bot and load test image
|
||||
|
||||
Reference in New Issue
Block a user