(new): v1.2 release
Golang lint / lint (push) Successful in 11m32s

This commit is contained in:
2026-08-19 14:58:25 +03:00
parent f03a081ed6
commit 29b208eeec
79 changed files with 7301 additions and 2060 deletions
+26
View File
@@ -2,6 +2,7 @@ package tgapi
import (
"encoding/json"
"errors"
"strings"
"testing"
)
@@ -266,3 +267,28 @@ func TestUnmarshalRichBlockRejectsMalformedFields(t *testing.T) {
})
}
}
func TestUnmarshalRichMessageStrict(t *testing.T) {
for _, raw := range []string{`null`, `{}`, `{"blocks":null}`, `{"blocks":{}}`} {
t.Run(raw, func(t *testing.T) {
if _, err := UnmarshalRichMessageStrict([]byte(raw)); err == nil {
t.Fatal("expected strict decoder error")
}
})
}
if _, err := UnmarshalRichMessageStrict([]byte(`{"blocks":[]}`)); err != nil {
t.Fatalf("strict decoder rejected an empty blocks array: %v", err)
}
}
func TestRichJSONStructuralLimits(t *testing.T) {
deep := strings.Repeat("[", maximumRichJSONDepth+1) + `"x"` + strings.Repeat("]", maximumRichJSONDepth+1)
if _, err := UnmarshalRichText([]byte(deep)); !errors.Is(err, ErrRichJSONDepth) {
t.Fatalf("expected ErrRichJSONDepth, got %v", err)
}
wide := "[" + strings.Repeat("0,", maximumRichJSONNodes) + "0]"
if _, err := UnmarshalRichText([]byte(wide)); !errors.Is(err, ErrRichJSONNodes) {
t.Fatalf("expected ErrRichJSONNodes, got %v", err)
}
}