src to pkg, impl lobby.Closed
This commit is contained in:
37
pkg/state/lobby/internal/event_test.go
Normal file
37
pkg/state/lobby/internal/event_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package lobby_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
lobby "gitea/price-is-wrong/pkg/state/lobby/internal"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMarshalUnmarshal(t *testing.T) {
|
||||
cases := map[string]struct {
|
||||
e lobby.Event
|
||||
}{
|
||||
"PlayerJoin": {e: &lobby.PlayerJoin{ID: 1}},
|
||||
"PlayerLeave": {e: &lobby.PlayerLeave{ID: 1}},
|
||||
}
|
||||
|
||||
for name, d := range cases {
|
||||
c := d
|
||||
t.Run(name, func(t *testing.T) {
|
||||
b, err := lobby.MarshalEvent(c.e)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("marshalled: %s", b)
|
||||
|
||||
e, err := lobby.ParseEvent(b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Logf("unmarshalled: %+v", e)
|
||||
|
||||
if fmt.Sprintf("%+v", c.e) != fmt.Sprintf("%+v", e) {
|
||||
t.Errorf("expected %+v but got %+v", c.e, e)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user