test: align bridge and geminiadapter tests with new protocol and routing
This commit is contained in:
parent
fc2629a0a0
commit
97c443834f
@ -20,7 +20,7 @@ func TestResolveGatewayReportedRemoteAddressUsesBuiltInOpenClawEndpoint(t *testi
|
||||
},
|
||||
})
|
||||
|
||||
const want = "openclaw.svc.plus:443"
|
||||
const want = "xworkmate-bridge.svc.plus:443"
|
||||
if got != want {
|
||||
t.Fatalf("resolveGatewayReportedRemoteAddress() = %q, want %q", got, want)
|
||||
}
|
||||
@ -42,7 +42,7 @@ func TestResolveGatewayReportedRemoteAddressNormalizesExplicitPublicRemoteHost(
|
||||
},
|
||||
})
|
||||
|
||||
const want = "openclaw.svc.plus:443"
|
||||
const want = "xworkmate-bridge.svc.plus:443"
|
||||
if got != want {
|
||||
t.Fatalf("resolveGatewayReportedRemoteAddress() = %q, want %q", got, want)
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ func (s *Server) handleCompatSessionRequest(method string, params map[string]any
|
||||
}
|
||||
|
||||
sessionsHistory := append([]string(nil), state.history...)
|
||||
sessionsHistory = append(sessionsHistory, taskPrompt)
|
||||
sessionsHistory = append(sessionsHistory, "USER: "+taskPrompt)
|
||||
composedPrompt := shared.ComposeHistoryPrompt(sessionsHistory)
|
||||
output, err := s.sessionRunner(context.Background(), model, composedPrompt, workingDirectory)
|
||||
if err != nil {
|
||||
@ -409,7 +409,7 @@ func (s *Server) handleCompatSessionRequest(method string, params map[string]any
|
||||
state = &adapterSession{}
|
||||
s.sessions[sessionID] = state
|
||||
}
|
||||
state.history = sessionsHistory
|
||||
state.history = append(sessionsHistory, "ASSISTANT: "+output)
|
||||
state.model = model
|
||||
state.workingDirectory = workingDirectory
|
||||
state.lastOutput = output
|
||||
|
||||
@ -157,7 +157,8 @@ func TestHandleSessionMessageReusesAdapterLocalHistory(t *testing.T) {
|
||||
}
|
||||
return "first-reply", nil
|
||||
}
|
||||
expected := "## User Turn 1\nFirst turn\n\n## User Turn 2\nSecond turn"
|
||||
// Match the format from shared.ComposeHistoryPrompt with ASSISTANT: prefix added in server.go
|
||||
expected := "## User Turn 1\nFirst turn\n\n## Assistant Response\nfirst-reply\n\n## User Turn 2\nSecond turn"
|
||||
if prompt != expected {
|
||||
t.Fatalf("unexpected second prompt %q", prompt)
|
||||
}
|
||||
|
||||
@ -185,9 +185,21 @@ func ComposeHistoryPrompt(history any) string {
|
||||
if len(h) == 0 {
|
||||
return ""
|
||||
}
|
||||
for index, turn := range h {
|
||||
_, _ = fmt.Fprintf(&builder, "## Turn %d\n", index+1)
|
||||
builder.WriteString(turn)
|
||||
turn := 1
|
||||
for _, turnText := range h {
|
||||
if strings.HasPrefix(turnText, "ASSISTANT: ") {
|
||||
builder.WriteString("## Assistant Response\n")
|
||||
builder.WriteString(strings.TrimPrefix(turnText, "ASSISTANT: "))
|
||||
} else if strings.HasPrefix(turnText, "USER: ") {
|
||||
_, _ = fmt.Fprintf(&builder, "## User Turn %d\n", turn)
|
||||
builder.WriteString(strings.TrimPrefix(turnText, "USER: "))
|
||||
turn++
|
||||
} else {
|
||||
// Default to User Turn if no prefix matches (for tests and legacy compatibility)
|
||||
_, _ = fmt.Fprintf(&builder, "## User Turn %d\n", turn)
|
||||
builder.WriteString(turnText)
|
||||
turn++
|
||||
}
|
||||
builder.WriteString("\n\n")
|
||||
}
|
||||
case []map[string]string:
|
||||
|
||||
@ -132,10 +132,15 @@ func TestHandleVaultKVToolListsSecretKeys(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHandleVaultKVToolRequiresEnvironment(t *testing.T) {
|
||||
// Explicitly clear relevant environment variables to ensure we test the validation logic
|
||||
t.Setenv("VAULT_SERVER_URL", "")
|
||||
t.Setenv("VAULT_SERVER_ROOT_ACCESS_TOKEN", "")
|
||||
|
||||
_, err := HandleVaultKVTool(map[string]any{
|
||||
"operation": "read",
|
||||
"path": "apps/demo",
|
||||
})
|
||||
// We want to catch the specific validation error message
|
||||
if err == nil || !strings.Contains(err.Error(), "VAULT_SERVER_URL") {
|
||||
t.Fatalf("expected missing environment error, got %v", err)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user