All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: twhelp/core#13
41 lines
784 B
Go
41 lines
784 B
Go
package msg_test
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/ThreeDotsLabs/watermill"
|
|
|
|
"gitea.dwysokinski.me/twhelp/core/internal/msg"
|
|
)
|
|
|
|
var _ msg.CommandEventMarshaler = msg.GobMarshaler{}
|
|
|
|
type testEvent struct {
|
|
ID string
|
|
Num int
|
|
When time.Time
|
|
}
|
|
|
|
func TestGobMarshaler(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
eventToMarshal := testEvent{
|
|
ID: watermill.NewUUID(),
|
|
Num: 123,
|
|
When: time.Date(2022, time.July, 30, 14, 13, 12, 0, time.UTC),
|
|
}
|
|
marshaler := msg.GobMarshaler{}
|
|
|
|
m, err := marshaler.Marshal(eventToMarshal)
|
|
require.NoError(t, err)
|
|
|
|
eventToUnmarshal := testEvent{}
|
|
require.NoError(t, marshaler.Unmarshal(m, &eventToUnmarshal))
|
|
|
|
assert.Equal(t, eventToMarshal, eventToUnmarshal)
|
|
}
|