package mapping import ( "errors" "strings" "testing" ) func TestShortErr_DefaultLimit(t *testing.T) { t.Parallel() msg := "x" + strings.Repeat("a", 260) got := shortErr(errors.New(msg)) if len(got) != 183 { t.Fatalf("expected default truncated len 183, got %d", len(got)) } if !strings.HasSuffix(got, "...") { t.Fatalf("expected ellipsis suffix, got %q", got) } } func TestShortErr_OpenAICompatibleEmptyContentUsesLongerLimit(t *testing.T) { t.Parallel() prefix := "empty openai-compatible response content (choices_len=1; choices0={index:number,finish_reason:string,message:object}; message={content:array,role:string}; message_content_type=array; message_content_len=0; top={choices:array,id:string}) " got := shortErr(errors.New(prefix + strings.Repeat("x", 260))) if len(got) != 423 { t.Fatalf("expected openai-compatible truncated len 423, got %d", len(got)) } if !strings.HasPrefix(got, "empty openai-compatible response content (") { t.Fatalf("expected openai-compatible prefix, got %q", got) } if !strings.HasSuffix(got, "...") { t.Fatalf("expected ellipsis suffix, got %q", got) } }