fix(release): 发布回归 - 修复资源引用保护并校准验证合同
This commit is contained in:
1 parent
04f49768cd
commit
037b288668
19 files changed
+363
-105
No files matched your search
@@ -6,6 +6,8 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -133,7 +135,7 @@ func TestPrepareOfficialGeminiAgentCacheCreatesAndReusesStablePrefix(t *testing.
|
||||
stableInstruction := strings.Repeat("stable system instruction ", 1000)
|
||||
spec := protocol.RequestSpec{
|
||||
Method: http.MethodPost,
|
||||
Path: "/models/gemini-test:generateContent",
|
||||
Path: "/v1beta/models/gemini-test:generateContent",
|
||||
ContentType: "application/json",
|
||||
Body: map[string]any{
|
||||
"systemInstruction": map[string]any{"parts": []any{map[string]any{"text": stableInstruction}}},
|
||||
@@ -142,6 +144,24 @@ func TestPrepareOfficialGeminiAgentCacheCreatesAndReusesStablePrefix(t *testing.
|
||||
"contents": []any{map[string]any{"role": "user", "parts": []any{map[string]any{"text": "hello"}}}},
|
||||
},
|
||||
}
|
||||
// Build the request through the shipped plugin, so the fixture cannot
|
||||
// silently diverge from its versioned endpoint or body mapping.
|
||||
manifest, err := os.ReadFile(filepath.Join("..", "..", "..", "plugin-packages", "google-gemini-generate-content", "manifest.json"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
adapter, err := protocol.LoadManifest(manifest)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
agentAdapter, ok := adapter.(protocol.AgentAdapter)
|
||||
if !ok {
|
||||
t.Fatal("official Gemini plugin does not support Agent requests")
|
||||
}
|
||||
spec, err = agentAdapter.BuildAgent(ctx, protocol.AgentRequestContext{BaseURL: server.URL, Model: input.Config.Model, Request: map[string]any{"gemini": spec.Body}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
prepared, used, err := prepareOfficialGeminiAgentCache(ctx, input, spec)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user