github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/remote/serializer_test.go (about) 1 package remote 2 3 import ( 4 "testing" 5 6 "github.com/asynkron/protoactor-go/actor" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 //func TestJsonSerializer_round_trip(t *testing.T) { 11 // m := &ActorPidRequest{ 12 // Kind: "abc", 13 // Name: "def", 14 // } 15 // b, typeName, _ := Serialize(m, 1) 16 // res, err := Deserialize(b, typeName, 1) 17 // 18 // assert.Nil(t, err) 19 // 20 // var typed = res.(*ActorPidRequest) 21 // assert.Equal(t, "remote.ActorPidRequest", typeName) 22 // assert.Equal(t, m, typed) 23 //} 24 // 25 //func TestJsonSerializer_Serialize_PID_raw(t *testing.T) { 26 // system := actor.NewActorSystem() 27 // m, _ := system.Root.SpawnNamed(actor.PropsFromFunc(func(ctx actor.Context) {}), "actorpid") 28 // var ser = jsonpb.Marshaler{} 29 // res, _ := ser.MarshalToString(m) 30 // assert.Equal(t, "{\"Address\":\"nonhost\",\"Id\":\"actorpid\"}", res) 31 //} 32 // 33 //func TestJsonSerializer_Serialize_PID(t *testing.T) { 34 // system := actor.NewActorSystem() 35 // m := system.NewLocalPID("foo") 36 // b, typeName, _ := Serialize(m, 1) 37 // res, err := Deserialize(b, typeName, 1) 38 // 39 // assert.Nil(t, err) 40 // 41 // var typed = res.(*actor.PID) 42 // assert.Equal(t, "actor.PID", typeName) 43 // assert.Equal(t, m, typed) 44 //} 45 46 func TestProtobufSerializer_Serialize_PID(t *testing.T) { 47 system := actor.NewActorSystem() 48 m := system.NewLocalPID("foo") 49 b, typeName, _ := Serialize(m, 0) 50 res, err := Deserialize(b, typeName, 0) 51 52 assert.Nil(t, err) 53 54 typed := res.(*actor.PID) 55 assert.Equal(t, "actor.PID", typeName) 56 assert.True(t, m.Equal(typed)) 57 }