Sub2API v1.0 - AI API 网关(二开初始版本,基于上游 Wei-Shaw/sub2api)
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
Release / update-version (push) Has been cancelled
Release / build-frontend (push) Has been cancelled
Release / release (push) Has been cancelled
Release / sync-version-file (push) Has been cancelled
CI / shell (push) Canceled after 0s
CI / test (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CI / golangci-lint (push) Canceled after 0s
Security Scan / backend-security (push) Canceled after 0s
Security Scan / frontend-security (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/Wei-Shaw/sub2api/internal/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSeedOpenAIForwardImageIntentHint(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
tests := []struct {
|
||||
name string
|
||||
channelMapped bool
|
||||
imageIntent bool
|
||||
wantHint bool
|
||||
}{
|
||||
{name: "seed true", imageIntent: true, wantHint: true},
|
||||
{name: "seed false", imageIntent: false, wantHint: true},
|
||||
{name: "mapped body stays unknown", channelMapped: true, imageIntent: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
c := &gin.Context{}
|
||||
service.SetOpenAIClientTransport(c, service.OpenAIClientTransportHTTP)
|
||||
|
||||
seedOpenAIForwardImageIntentHint(c, tt.channelMapped, tt.imageIntent)
|
||||
|
||||
var hintValues []bool
|
||||
for _, value := range c.Keys {
|
||||
if hint, ok := value.(bool); ok {
|
||||
hintValues = append(hintValues, hint)
|
||||
}
|
||||
}
|
||||
if !tt.wantHint {
|
||||
require.Empty(t, hintValues)
|
||||
return
|
||||
}
|
||||
require.Equal(t, []bool{tt.imageIntent}, hintValues)
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user