ggbdpq's change before this one adds xai, writer, moonshot and nvidia to vendorDot, with six pairs read off the catalog. This test reads all 200 amazon-bedrock ids from models.dev's list of today (kept in testdata) and checks that each one answered by its own name, or by maker.name, is no swap. A maker the list gains later and vendorDot lacks fails here once the testdata is refreshed. The four makers are the only ones missing today: the list's makers are amazon, anthropic, deepseek, google, meta, minimax, mistral, moonshot, moonshotai, nvidia, openai, qwen, writer, xai and zai. Reported by gua2100 (ggbdpq) on GitHub. Run (on mote): - go test -tags nogui -count=1 ./internal/usage ok. - go test -tags nogui -count=1 -run 'Bedrock|Swapped|Served|RelayRenamed|Rename' ./internal/gateway ok. - go vet -tags nogui of both packages on darwin, GOOS=linux and GOOS=windows clean; gofmt -l clean. Broken by hand: with origin/main's served.go put back, this test fails on 21 pairs (xai 10, writer 6, nvidia 4, moonshot 1), and TestBedrockProfileAnsweredByItsModelIsNoSwap fails on ggbdpq's rows. Not tried: a real Bedrock account; a full go test ./....
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package usage
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Every Bedrock id models.dev lists is a geography (or none), a maker and
|
|
// the model's own name. A reply naming the model by its own name, or by
|
|
// maker.name, is that model: no maker of the list may be missing from
|
|
// vendorDot (#2199: xai, writer, moonshot and nvidia were).
|
|
func TestBedrockListedMakersAnsweredByOwnNameAreNoSwap(t *testing.T) {
|
|
b, err := os.ReadFile("testdata/bedrock-ids-models.dev-2026-10-28.txt")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
geos := map[string]bool{"global": true, "us": true, "us-gov": true, "eu": true, "apac": true, "jp": true, "au": true, "ca": true, "in": true}
|
|
n := 0
|
|
for _, id := range strings.Fields(string(b)) {
|
|
rest := id
|
|
if g, r, ok := strings.Cut(rest, "."); ok && geos[g] {
|
|
rest = r
|
|
}
|
|
maker, own, ok := strings.Cut(rest, ".")
|
|
if !ok {
|
|
t.Errorf("%s has no maker", id)
|
|
continue
|
|
}
|
|
n++
|
|
for _, served := range []string{own, maker + "." + own} {
|
|
if Swapped(id, served) {
|
|
t.Errorf("Swapped(%q, %q) = true: maker %q isn't stripped", id, served, maker)
|
|
}
|
|
}
|
|
}
|
|
if n < 100 {
|
|
t.Fatalf("read %d ids, want the whole list", n)
|
|
}
|
|
}
|