- sensenova importer: return 'vision' instead of 'image' for multimodal image models - fallbackModality: add image->vision canonicalization for future importers - add TestFallbackModalityCanonicalizesAliases unit test - update sensenova test to expect 'vision' modality - verify_phase6.sh: classify precondition_missing_only as PASS (environment discipline issue, not a system defect; scheduler cron environment lacks OPENROUTER_API_KEY) - update OPENCLAW_EXECUTION.md with current gate truth
59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
//go:build llm_script
|
|
|
|
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"sync/atomic"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestFetchRawPricingPageRetriesTransientStatus(t *testing.T) {
|
|
var attempts int32
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
current := atomic.AddInt32(&attempts, 1)
|
|
if current == 1 {
|
|
http.Error(w, "temporary", http.StatusServiceUnavailable)
|
|
return
|
|
}
|
|
_, _ = w.Write([]byte("ok"))
|
|
}))
|
|
defer server.Close()
|
|
|
|
client := &http.Client{Timeout: 2 * time.Second}
|
|
body, err := fetchRawPricingPage(server.URL, "", client)
|
|
if err != nil {
|
|
t.Fatalf("fetchRawPricingPage returned error: %v", err)
|
|
}
|
|
if body != "ok" {
|
|
t.Fatalf("body = %q, want ok", body)
|
|
}
|
|
if got := atomic.LoadInt32(&attempts); got != 2 {
|
|
t.Fatalf("attempts = %d, want 2", got)
|
|
}
|
|
}
|
|
|
|
func TestIsRetriablePricingFetchErrorRecognizesEOF(t *testing.T) {
|
|
if !isRetriablePricingFetchError(errString("unexpected EOF")) {
|
|
t.Fatalf("expected EOF to be retriable")
|
|
}
|
|
if isRetriablePricingFetchError(errString("bad request")) {
|
|
t.Fatalf("expected bad request to be non-retriable")
|
|
}
|
|
}
|
|
|
|
func TestFallbackModalityCanonicalizesAliases(t *testing.T) {
|
|
if got := fallbackModality("image"); got != "vision" {
|
|
t.Fatalf("fallbackModality(image) = %q, want vision", got)
|
|
}
|
|
if got := fallbackModality(" "); got != "text" {
|
|
t.Fatalf("fallbackModality(blank) = %q, want text", got)
|
|
}
|
|
}
|
|
|
|
type errString string
|
|
|
|
func (e errString) Error() string { return string(e) }
|