package protocol

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestMessage_Decode(t *testing.T) {
	msg := &Message{
		QueueName:  "123",
		Id:         "123",
		Ts:         nil,
		Type:       "",
		Data:       "",
		RuleChanId: "",
		RuleNodeId: "",
		Callback:   nil,
		MetaData: map[string]interface{}{
			"name": 123,
		},
		Originator: "456",
	}
	result, err := msg.Encode()
	if err != nil {
		t.Error(err)
	}

	newMsg := new(Message)
	err = newMsg.Decode(result)
	if err != nil {
		t.Error(err)
	}
	assert.Equal(t, newMsg, msg, "not equal")
}
