| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package mock_hand_sub_local
- import (
- "strings"
- "testing"
- "gitp78su.ipnodns.ru/svi/kern/v4/lev0/alias"
- )
- type tester struct {
- t *testing.T
- hand *MockHandlerSub
- }
- func TestMockHandleServe(t *testing.T) {
- sf := &tester{
- t: t,
- }
- sf.new()
- sf.back()
- }
- // Проверка обратного вызова.
- func (sf *tester) back() {
- sf.t.Log("back")
- sf.backGood1()
- }
- func (sf *tester) backGood1() {
- sf.t.Log("backGood1")
- sf.hand.FnBack([]byte("test_msg"))
- if sf.hand.Msg() != "test_msg" {
- sf.t.Fatalf("backGood1(): binMsg(%v)!='test_msg'", string(sf.hand.Msg_))
- }
- }
- // Создание мок-обработчика запросов.
- func (sf *tester) new() {
- sf.t.Log("new")
- sf.newGood1()
- }
- var (
- qTopicTest = alias.NewATopic("test_topic")
- )
- func (sf *tester) newGood1() {
- sf.t.Log("newGood1")
- sf.hand = NewMockHandlerSub(qTopicTest, "test_name")
- if sf.hand == nil {
- sf.t.Fatalf("newGood1(): handler==nil")
- }
- if name := sf.hand.Name(); !strings.Contains(name.Get(), "test_name_") {
- sf.t.Fatalf("newGood1(): name(%v)!='test_name_'", name)
- }
- if topic := sf.hand.Topic(); topic.Get() != "test_topic" {
- sf.t.Fatalf("newGood1(): topic(%v)!='test_topic'", topic)
- }
- if msg := sf.hand.Msg(); msg != "" {
- sf.t.Fatalf("newGood1(): msg not empty")
- }
- }
|