platform
This commit is contained in:
1 parent
e706f7d907
commit
21bcb63440
42 files changed
+5903
No files matched your search
@@ -0,0 +1,30 @@
|
||||
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])
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user