package order import "testing" func TestCreatedRoundTrip(t *testing.T) { in := Created{ OrderID: "ord-1", OrderReference: "REF-1", CartID: "cart-9", Country: "se", Currency: "SEK", CustomerEmail: "a@b.c", Lines: []Line{{SKU: "ABC", Quantity: 2, Location: "store-7"}, {SKU: "DEF", Quantity: 1}}, PlacedAtMs: 123, } raw, err := in.Encode() if err != nil { t.Fatalf("encode: %v", err) } out, err := Decode(raw) if err != nil { t.Fatalf("decode: %v", err) } if out.OrderID != in.OrderID || out.Country != in.Country || len(out.Lines) != 2 { t.Fatalf("round-trip mismatch: got %+v, want %+v", out, in) } if out.Lines[0].SKU != "ABC" || out.Lines[0].Quantity != 2 || out.Lines[0].Location != "store-7" { t.Errorf("line[0] mismatch: %+v", out.Lines[0]) } }