76ba500417
CI / docker (push) Successful in 2m4s
OpenAI-compatible AI gateway with Vue admin UI, multi-provider egress, ingress key governance, monitoring, and security controls. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
803 B
Go
27 lines
803 B
Go
package anthropic
|
|
|
|
import "testing"
|
|
|
|
func TestConvertOpenAIContentBlocks_TextAndImage(t *testing.T) {
|
|
content := []any{
|
|
map[string]any{"type": "text", "text": "describe this"},
|
|
map[string]any{"type": "image_url", "image_url": map[string]any{"url": "https://example.com/a.png"}},
|
|
}
|
|
blocks, ok := convertOpenAIContentBlocks(content).([]map[string]any)
|
|
if !ok || len(blocks) != 2 {
|
|
t.Fatalf("expected 2 blocks, got %#v", convertOpenAIContentBlocks(content))
|
|
}
|
|
if blocks[0]["text"] != "describe this" {
|
|
t.Fatalf("unexpected text block: %#v", blocks[0])
|
|
}
|
|
if blocks[1]["type"] != "image" {
|
|
t.Fatalf("unexpected image block: %#v", blocks[1])
|
|
}
|
|
}
|
|
|
|
func TestExtractOpenAIContent_String(t *testing.T) {
|
|
if got := extractOpenAIContent("hello"); got != "hello" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|