mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2026-12-01 23:07:51 +00:00
fix(translate): answer a request whose texts are all empty with 200 as well
Every text is answered now, blank or not, so the all-empty case needs no rule of its own: "" and [""] are texts with nothing to translate in them, and they are answered with themselves like any other blank text. A missing or null `text` decodes to the one empty string and is answered the same way. The 404 is left for a request that names no text at all: `"text": []`, the one shape there is nothing to answer with. Nothing else errors on emptiness. Refs #244.
This commit is contained in:
@@ -104,10 +104,7 @@ func TestTranslateByDLXRejectsOversizedTextsBeforeUpstream(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
_, length, ok := textsToTranslate(tt.texts)
|
||||
if !ok {
|
||||
t.Fatalf("textsToTranslate(%q) reported no text", tt.texts)
|
||||
}
|
||||
_, length := textsToTranslate(tt.texts)
|
||||
if length <= maxFreeTextLength {
|
||||
t.Fatalf("textsToTranslate(%q) = %d, which is not over the limit", tt.texts, length)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user