docs: reorder & testing
This commit is contained in:
@@ -14,6 +14,40 @@ import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func TestGameReportRequestPayloadRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
source := &model.GameReportRequest{
|
||||
GameID: uuid.MustParse("11111111-2222-3333-4444-555555555555"),
|
||||
Turn: 42,
|
||||
}
|
||||
|
||||
payload, err := GameReportRequestToPayload(source)
|
||||
if err != nil {
|
||||
t.Fatalf("encode game report request: %v", err)
|
||||
}
|
||||
|
||||
decoded, err := PayloadToGameReportRequest(payload)
|
||||
if err != nil {
|
||||
t.Fatalf("decode game report request: %v", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(source, decoded) {
|
||||
t.Fatalf("round-trip mismatch\nsource: %#v\ndecoded: %#v", source, decoded)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGameReportRequestRejectsEmptyAndNil(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if _, err := GameReportRequestToPayload(nil); err == nil {
|
||||
t.Fatalf("expected error encoding nil request")
|
||||
}
|
||||
if _, err := PayloadToGameReportRequest(nil); err == nil {
|
||||
t.Fatalf("expected error decoding empty payload")
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportToPayloadAndPayloadToReportRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user