кастомный echotron + fix текста

This commit is contained in:
Artem Tsyrulnikov
2026-02-19 11:13:45 +03:00
parent 4b9e5bf4df
commit 5e25ea1a59
57 changed files with 11371 additions and 6 deletions

View File

@@ -0,0 +1,72 @@
package echotron
import (
"net/url"
"reflect"
"testing"
)
type scanTest struct {
i any
predefined url.Values
expected url.Values
}
func TestScan(t *testing.T) {
tests := []scanTest{
{
i: CommandOptions{
LanguageCode: "it",
Scope: BotCommandScope{Type: BCSTChat, ChatID: 33288},
},
predefined: url.Values{"foo": {"bar"}},
expected: url.Values{
"foo": {"bar"},
"language_code": {"it"},
"scope": {`{"type":"chat","chat_id":33288,"user_id":0}`},
},
},
}
for i, tt := range tests {
result := scan(tt.i, tt.predefined)
if !reflect.DeepEqual(tt.expected, result) {
t.Fatalf("test #%d: result differs from expected value\n", i)
}
}
}
func TestToStringDefault(t *testing.T) {
ret := toString(reflect.ValueOf(nil))
if ret != "" {
t.Fatalf("expected empty string, got %+v", ret)
}
}
func TestUrlValues(t *testing.T) {
ret := urlValues(nil)
if ret != nil {
t.Fatalf("expected nil, got %+v", ret)
}
}
func TestAddValues(t *testing.T) {
vals := url.Values{}
ret := addValues(vals, nil)
if !reflect.DeepEqual(vals, ret) {
t.Fatalf("expected nil, got %+v", ret)
}
}
func TestAddValuesNil(t *testing.T) {
opts := MessageOptions{ParseMode: MarkdownV2}
vals := urlValues(opts)
ret := addValues(nil, opts)
if !reflect.DeepEqual(vals, ret) {
t.Fatalf("expected %+v, got %+v", vals, ret)
}
}