release: prepare v1.2.31
Docker Release / Check web and api (push) Waiting to run
Docker Release / Resolve release tag (push) Blocked by required conditions
Docker Release / Build and publish all-in-one (push) Blocked by required conditions
Docker Release / Build and publish api (push) Blocked by required conditions
Docker Release / Build and publish web (push) Blocked by required conditions
Docker Release / Build and publish dovecot (push) Blocked by required conditions
Docker Release / Build and publish postfix (push) Blocked by required conditions
Docker Release / Build and publish rspamd (push) Blocked by required conditions
Docker Release / Create GitHub release (push) Blocked by required conditions

This commit is contained in:
zxyszx
2026-08-12 06:01:56 +08:00
parent c92140c9cc
commit 9a572e0100
5 changed files with 155 additions and 32 deletions
+21 -1
View File
@@ -1,6 +1,10 @@
package app
import "testing"
import (
"context"
"strings"
"testing"
)
func TestParseGoogleTranslateResponse(t *testing.T) {
raw := []any{
@@ -20,6 +24,22 @@ func TestParseGoogleTranslateResponse(t *testing.T) {
}
}
func TestTranslateHTMLTextNodesWithPreservesMarkupAndSkipsCode(t *testing.T) {
translator := func(_ context.Context, text, target string) (string, string, error) {
return strings.ToUpper(text) + "-" + target, "en", nil
}
got, err := translateHTMLTextNodesWith(context.Background(), nil, `<p>Hello <strong>world</strong></p><pre>keep me</pre>`, "zh-CN", 100, translator)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(got, `<p>HELLO-zh-CN <strong>WORLD-zh-CN</strong></p>`) {
t.Fatalf("translated HTML = %q", got)
}
if !strings.Contains(got, `<pre>keep me</pre>`) {
t.Fatalf("code block was translated: %q", got)
}
}
func TestTruncateRunes(t *testing.T) {
got, truncated := truncateRunes("你好world", 4)
if got != "你好wo" || !truncated {