Skip to content

Commit 3033540

Browse files
committed
Test products report
1 parent dafcead commit 3033540

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

api/reports_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,22 @@ func TestSalesReport(t *testing.T) {
2424
assert.Equal(t, uint64(2), row.Orders)
2525
})
2626
}
27+
28+
func TestProductsReport(t *testing.T) {
29+
test := NewRouteTest(t)
30+
token := testAdminToken("admin-yo", "[email protected]")
31+
recorder := test.TestEndpoint(http.MethodGet, "/reports/products", nil, token)
32+
33+
report := []productsRow{}
34+
extractPayload(t, http.StatusOK, recorder, &report)
35+
assert.Len(t, report, 3)
36+
prod1 := report[0]
37+
assert.Equal(t, "234-fancy-belts", prod1.Sku)
38+
assert.Equal(t, uint64(45), prod1.Total)
39+
prod2 := report[1]
40+
assert.Equal(t, "123-i-can-fly-456", prod2.Sku)
41+
assert.Equal(t, uint64(24), prod2.Total)
42+
prod3 := report[2]
43+
assert.Equal(t, "456-i-rollover-all-things", prod3.Sku)
44+
assert.Equal(t, uint64(10), prod3.Total)
45+
}

0 commit comments

Comments
 (0)