Exemple #1
0
func TestSubscription(t *testing.T) {
	g := Goblin(t)
	RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) })

	g.Describe("Subscription Status", func() {
		var server *bogus.Bogus
		var id, authToken string
		g.BeforeEach(func() {
			id = "AXXXXXXXX"
			authToken = "superhash"

			server = bogus.New()
			server.SetStatus(200)
			server.Start()
		})

		g.It("should get a subscriptions status", func() {
			server.SetPayload(greenStatusXML)

			s := &seller.Seller{
				id,
				authToken,
				marketplace.Marketplace{
					"NA",
					"US",
					fmt.Sprintf("http://%v", net.JoinHostPort(server.HostPort())),
					"ABCDEFG",
				},
				auth.Auth{},
			}

			stat, err := Status(s)
			Expect(err).NotTo(HaveOccurred())
			Expect(stat).To(Equal("GREEN"))
			Expect(server.Hits()).To(Equal(1))
		})

		g.It("should return an error when it receives an error from MWS", func() {
			server.SetPayload(errorXML)

			s := &seller.Seller{
				id,
				authToken,
				marketplace.Marketplace{
					"NA",
					"US",
					fmt.Sprintf("http://%v", net.JoinHostPort(server.HostPort())),
					"ABCDEFG",
				},
				auth.Auth{},
			}
			stat, err := Status(s)
			Expect(err).To(HaveOccurred())
			Expect(stat).To(Equal(""))
			Expect(server.Hits()).To(Equal(1))
		})
	})

	g.Describe("Test Notification", func() {
		var server *bogus.Bogus
		var id, authToken string
		g.BeforeEach(func() {
			id = "AXXXXXXXX"
			authToken = "superhash"

			server = bogus.New()
			server.SetStatus(200)
			server.Start()
		})

		g.It("should send a request for a test message on a given queue", func() {
			server.SetPayload(testMessageXML)

			s := &seller.Seller{
				id,
				authToken,
				marketplace.Marketplace{
					"NA",
					"US",
					fmt.Sprintf("http://%v", net.JoinHostPort(server.HostPort())),
					"ABCDEFG",
				},
				auth.Auth{},
			}
			err := Test(s, []string{"queue"})
			Expect(err).NotTo(HaveOccurred())
			Expect(server.Hits()).To(Equal(1))
		})

		g.It("should return an error when it receives an error from MWS", func() {
			server.SetPayload(errorXML)

			s := &seller.Seller{
				id,
				authToken,
				marketplace.Marketplace{
					"NA",
					"US",
					fmt.Sprintf("http://%v", net.JoinHostPort(server.HostPort())),
					"ABCDEFG",
				},
				auth.Auth{},
			}
			err := Test(s, []string{"queue"})
			Expect(err).To(HaveOccurred())
			Expect(server.Hits()).To(Equal(1))
		})
	})
}
func TestShopifyProducts(t *testing.T) {
	g := Goblin(t)
	RegisterFailHandler(func(m string, _ ...int) { g.Fail(m) })

	g.Describe("Products", func() {
		var mockShopify *bogus.Bogus

		g.BeforeEach(func() {
			mockShopify = bogus.New()
			mockShopify.Start()
		})

		g.AfterEach(func() {
			mockShopify.Close()
		})

		g.Describe("Get All", func() {
			g.It("should get a list of products from shopify", func() {
				mockShopify.SetPayload([]byte(SampleProductsJson))
				mockShopify.SetStatus(http.StatusOK)
				host, port := mockShopify.HostPort()

				s := &Shopify{fmt.Sprintf("http://%s:%s", host, port)}
				c := &Credentials{"some-cart-hash", "oauthom"}

				p, err := s.GetProducts(c, nil)
				Expect(err).NotTo(HaveOccurred())
				Expect(p).NotTo(BeNil())
				Expect(len(p)).To(Equal(2))

				Expect(p[0].BodyHtml).To(ContainSubstring("It's the small iPod with one very big idea"))
				Expect(p[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:01"))
				Expect(p[0].Handle).To(Equal("ipod-nano"))
				Expect(p[0].Id).To(Equal(int64(632910392)))
				Expect(p[0].ProductType).To(Equal("Cult Products"))
				Expect(p[0].PublishedAt).To(Equal("2007-12-31T19:00:00-05:00"))
				Expect(p[0].PublishedScope).To(Equal("web"))
				Expect(p[0].TemplateSuffix).To(Equal(""))
				Expect(p[0].Title).To(Equal("IPod Nano - 8GB"))
				Expect(p[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:02"))
				Expect(p[0].Vendor).To(Equal("Apple"))
				Expect(p[0].Tags).To(Equal("Emotive, Flash Memory, MP3, Music"))

				Expect(len(p[0].Variants)).To(Equal(4))

				Expect(p[0].Variants[0].Barcode).To(Equal("1234_pink"))
				Expect(p[0].Variants[0].CompareAtPrice).To(Equal(""))
				Expect(p[0].Variants[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:03"))
				Expect(p[0].Variants[0].FulfillmentService).To(Equal("manual"))
				Expect(p[0].Variants[0].Grams).To(Equal(float64(200)))
				Expect(p[0].Variants[0].Id).To(Equal(int64(808950810)))
				Expect(p[0].Variants[0].InventoryManagement).To(Equal("shopify"))
				Expect(p[0].Variants[0].InventoryPolicy).To(Equal("continue"))
				Expect(p[0].Variants[0].Option1).To(Equal("Pink"))
				Expect(p[0].Variants[0].Option2).To(Equal(""))
				Expect(p[0].Variants[0].Option3).To(Equal(""))
				Expect(p[0].Variants[0].Position).To(Equal(1))
				Expect(p[0].Variants[0].Price).To(Equal("199.00"))
				Expect(p[0].Variants[0].ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Variants[0].RequiresShipping).To(BeTrue())
				Expect(p[0].Variants[0].Sku).To(Equal("IPOD2008PINK"))
				Expect(p[0].Variants[0].Taxable).To(BeTrue())
				Expect(p[0].Variants[0].Title).To(Equal("Pink"))
				Expect(p[0].Variants[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:04"))
				Expect(p[0].Variants[0].InventoryQuantity).To(Equal(int64(10)))
				Expect(p[0].Variants[0].OldInventoryQuantity).To(Equal(int64(10)))
				Expect(p[0].Variants[0].ImageId).To(Equal(int64(562641783)))
				Expect(p[0].Variants[0].Weight).To(Equal(0.2))
				Expect(p[0].Variants[0].WeightUnit).To(Equal("kg"))

				Expect(p[0].Variants[1].Barcode).To(Equal("1234_red"))
				Expect(p[0].Variants[1].CompareAtPrice).To(Equal(""))
				Expect(p[0].Variants[1].CreatedAt).To(Equal("2015-03-28T13:31:19-04:05"))
				Expect(p[0].Variants[1].FulfillmentService).To(Equal("manual"))
				Expect(p[0].Variants[1].Grams).To(Equal(float64(200)))
				Expect(p[0].Variants[1].Id).To(Equal(int64(49148385)))
				Expect(p[0].Variants[1].InventoryManagement).To(Equal("shopify"))
				Expect(p[0].Variants[1].InventoryPolicy).To(Equal("continue"))
				Expect(p[0].Variants[1].Option1).To(Equal("Red"))
				Expect(p[0].Variants[1].Option2).To(Equal(""))
				Expect(p[0].Variants[1].Option3).To(Equal(""))
				Expect(p[0].Variants[1].Position).To(Equal(2))
				Expect(p[0].Variants[1].Price).To(Equal("199.00"))
				Expect(p[0].Variants[1].ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Variants[1].RequiresShipping).To(BeTrue())
				Expect(p[0].Variants[1].Sku).To(Equal("IPOD2008RED"))
				Expect(p[0].Variants[1].Taxable).To(BeTrue())
				Expect(p[0].Variants[1].Title).To(Equal("Red"))
				Expect(p[0].Variants[1].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:06"))
				Expect(p[0].Variants[1].InventoryQuantity).To(Equal(int64(20)))
				Expect(p[0].Variants[1].OldInventoryQuantity).To(Equal(int64(20)))
				Expect(p[0].Variants[1].ImageId).To(Equal(int64(0)))
				Expect(p[0].Variants[1].Weight).To(Equal(0.2))
				Expect(p[0].Variants[1].WeightUnit).To(Equal("kg"))

				Expect(len(p[0].Options)).To(Equal(1))

				Expect(p[0].Options[0].Id).To(Equal(int64(594680422)))
				Expect(p[0].Options[0].Name).To(Equal("Title"))
				Expect(p[0].Options[0].Position).To(Equal(1))
				Expect(p[0].Options[0].ProductId).To(Equal(int64(632910392)))

				Expect(len(p[0].Images)).To(Equal(2))

				Expect(p[0].Images[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:07"))
				Expect(p[0].Images[0].Id).To(Equal(int64(850703190)))
				Expect(p[0].Images[0].Position).To(Equal(1))
				Expect(p[0].Images[0].ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Images[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:08"))
				Expect(p[0].Images[0].Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1427563879"))
				Expect(len(p[0].Images[0].VariantIds)).To(Equal(0))

				Expect(p[0].Images[1].CreatedAt).To(Equal("2015-03-28T13:31:19-04:09"))
				Expect(p[0].Images[1].Id).To(Equal(int64(562641783)))
				Expect(p[0].Images[1].Position).To(Equal(2))
				Expect(p[0].Images[1].ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Images[1].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:10"))
				Expect(p[0].Images[1].Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano-2.png?v=1427563879"))
				Expect(p[0].Images[1].VariantIds[0]).To(Equal(int64(808950810)))

				Expect(p[0].Image.CreatedAt).To(Equal("2015-03-28T13:31:19-04:11"))
				Expect(p[0].Image.Id).To(Equal(int64(850703190)))
				Expect(p[0].Image.Position).To(Equal(1))
				Expect(p[0].Image.ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Image.UpdatedAt).To(Equal("2015-03-28T13:31:19-04:12"))
				Expect(p[0].Image.Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1427563879"))
				Expect(len(p[0].Image.VariantIds)).To(Equal(0))

				Expect(len(p[1].Variants)).To(Equal(1))
				Expect(len(p[1].Options)).To(Equal(1))
				Expect(len(p[1].Images)).To(Equal(0))

				Expect(mockShopify.Hits()).To(Equal(1))
			})

			g.It("should return an offset list of products", func() {
				mockShopify.SetPayload([]byte(SampleProductsJson))
				mockShopify.SetStatus(http.StatusOK)
				host, port := mockShopify.HostPort()

				s := &Shopify{fmt.Sprintf("http://%s:%s", host, port)}
				c := &Credentials{"some-cart-hash", "oauthom"}

				params := url.Values{}
				params.Add("page", "2")

				p, err := s.GetProducts(c, params)
				Expect(err).NotTo(HaveOccurred())
				Expect(p).NotTo(BeNil())
				Expect(len(p)).To(Equal(2))

				Expect(p[0].BodyHtml).To(ContainSubstring("It's the small iPod with one very big idea"))
				Expect(p[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:01"))
				Expect(p[0].Handle).To(Equal("ipod-nano"))
				Expect(p[0].Id).To(Equal(int64(632910392)))
				Expect(p[0].ProductType).To(Equal("Cult Products"))
				Expect(p[0].PublishedAt).To(Equal("2007-12-31T19:00:00-05:00"))
				Expect(p[0].PublishedScope).To(Equal("web"))
				Expect(p[0].TemplateSuffix).To(Equal(""))
				Expect(p[0].Title).To(Equal("IPod Nano - 8GB"))
				Expect(p[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:02"))
				Expect(p[0].Vendor).To(Equal("Apple"))
				Expect(p[0].Tags).To(Equal("Emotive, Flash Memory, MP3, Music"))

				Expect(len(p[0].Variants)).To(Equal(4))

				Expect(p[0].Variants[0].Barcode).To(Equal("1234_pink"))
				Expect(p[0].Variants[0].CompareAtPrice).To(Equal(""))
				Expect(p[0].Variants[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:03"))
				Expect(p[0].Variants[0].FulfillmentService).To(Equal("manual"))
				Expect(p[0].Variants[0].Grams).To(Equal(float64(200)))
				Expect(p[0].Variants[0].Id).To(Equal(int64(808950810)))
				Expect(p[0].Variants[0].InventoryManagement).To(Equal("shopify"))
				Expect(p[0].Variants[0].InventoryPolicy).To(Equal("continue"))
				Expect(p[0].Variants[0].Option1).To(Equal("Pink"))
				Expect(p[0].Variants[0].Option2).To(Equal(""))
				Expect(p[0].Variants[0].Option3).To(Equal(""))
				Expect(p[0].Variants[0].Position).To(Equal(1))
				Expect(p[0].Variants[0].Price).To(Equal("199.00"))
				Expect(p[0].Variants[0].ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Variants[0].RequiresShipping).To(BeTrue())
				Expect(p[0].Variants[0].Sku).To(Equal("IPOD2008PINK"))
				Expect(p[0].Variants[0].Taxable).To(BeTrue())
				Expect(p[0].Variants[0].Title).To(Equal("Pink"))
				Expect(p[0].Variants[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:04"))
				Expect(p[0].Variants[0].InventoryQuantity).To(Equal(int64(10)))
				Expect(p[0].Variants[0].OldInventoryQuantity).To(Equal(int64(10)))
				Expect(p[0].Variants[0].ImageId).To(Equal(int64(562641783)))
				Expect(p[0].Variants[0].Weight).To(Equal(0.2))
				Expect(p[0].Variants[0].WeightUnit).To(Equal("kg"))

				Expect(p[0].Variants[1].Barcode).To(Equal("1234_red"))
				Expect(p[0].Variants[1].CompareAtPrice).To(Equal(""))
				Expect(p[0].Variants[1].CreatedAt).To(Equal("2015-03-28T13:31:19-04:05"))
				Expect(p[0].Variants[1].FulfillmentService).To(Equal("manual"))
				Expect(p[0].Variants[1].Grams).To(Equal(float64(200)))
				Expect(p[0].Variants[1].Id).To(Equal(int64(49148385)))
				Expect(p[0].Variants[1].InventoryManagement).To(Equal("shopify"))
				Expect(p[0].Variants[1].InventoryPolicy).To(Equal("continue"))
				Expect(p[0].Variants[1].Option1).To(Equal("Red"))
				Expect(p[0].Variants[1].Option2).To(Equal(""))
				Expect(p[0].Variants[1].Option3).To(Equal(""))
				Expect(p[0].Variants[1].Position).To(Equal(2))
				Expect(p[0].Variants[1].Price).To(Equal("199.00"))
				Expect(p[0].Variants[1].ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Variants[1].RequiresShipping).To(BeTrue())
				Expect(p[0].Variants[1].Sku).To(Equal("IPOD2008RED"))
				Expect(p[0].Variants[1].Taxable).To(BeTrue())
				Expect(p[0].Variants[1].Title).To(Equal("Red"))
				Expect(p[0].Variants[1].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:06"))
				Expect(p[0].Variants[1].InventoryQuantity).To(Equal(int64(20)))
				Expect(p[0].Variants[1].OldInventoryQuantity).To(Equal(int64(20)))
				Expect(p[0].Variants[1].ImageId).To(Equal(int64(0)))
				Expect(p[0].Variants[1].Weight).To(Equal(0.2))
				Expect(p[0].Variants[1].WeightUnit).To(Equal("kg"))

				Expect(len(p[0].Options)).To(Equal(1))

				Expect(p[0].Options[0].Id).To(Equal(int64(594680422)))
				Expect(p[0].Options[0].Name).To(Equal("Title"))
				Expect(p[0].Options[0].Position).To(Equal(1))
				Expect(p[0].Options[0].ProductId).To(Equal(int64(632910392)))

				Expect(len(p[0].Images)).To(Equal(2))

				Expect(p[0].Images[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:07"))
				Expect(p[0].Images[0].Id).To(Equal(int64(850703190)))
				Expect(p[0].Images[0].Position).To(Equal(1))
				Expect(p[0].Images[0].ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Images[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:08"))
				Expect(p[0].Images[0].Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1427563879"))
				Expect(len(p[0].Images[0].VariantIds)).To(Equal(0))

				Expect(p[0].Images[1].CreatedAt).To(Equal("2015-03-28T13:31:19-04:09"))
				Expect(p[0].Images[1].Id).To(Equal(int64(562641783)))
				Expect(p[0].Images[1].Position).To(Equal(2))
				Expect(p[0].Images[1].ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Images[1].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:10"))
				Expect(p[0].Images[1].Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano-2.png?v=1427563879"))
				Expect(p[0].Images[1].VariantIds[0]).To(Equal(int64(808950810)))

				Expect(p[0].Image.CreatedAt).To(Equal("2015-03-28T13:31:19-04:11"))
				Expect(p[0].Image.Id).To(Equal(int64(850703190)))
				Expect(p[0].Image.Position).To(Equal(1))
				Expect(p[0].Image.ProductId).To(Equal(int64(632910392)))
				Expect(p[0].Image.UpdatedAt).To(Equal("2015-03-28T13:31:19-04:12"))
				Expect(p[0].Image.Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1427563879"))
				Expect(len(p[0].Image.VariantIds)).To(Equal(0))

				Expect(len(p[1].Variants)).To(Equal(1))
				Expect(len(p[1].Options)).To(Equal(1))
				Expect(len(p[1].Images)).To(Equal(0))

				Expect(mockShopify.Hits()).To(Equal(1))
			})

			g.It("should return a limited list of products", func() {
				mockShopify.SetPayload([]byte(SampleProductsLimitedJson))
				mockShopify.SetStatus(http.StatusOK)
				host, port := mockShopify.HostPort()

				s := &Shopify{fmt.Sprintf("http://%s:%s", host, port)}
				c := &Credentials{"some-cart-hash", "oauthom"}
				params := url.Values{}
				params.Add("limit", "1")

				p, err := s.GetProducts(c, params)
				Expect(err).NotTo(HaveOccurred())
				Expect(p).NotTo(BeNil())
				Expect(len(p)).To(Equal(1))

				Expect(p[0].BodyHtml).To(ContainSubstring("The iPod Touch has the iPhone's multi-touch interface"))
				Expect(p[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:20"))
				Expect(p[0].Handle).To(Equal("ipod-touch"))
				Expect(p[0].Id).To(Equal(int64(921728736)))
				Expect(p[0].ProductType).To(Equal("Cult Products"))
				Expect(p[0].PublishedAt).To(Equal("2008-09-25T20:00:00-04:00"))
				Expect(p[0].PublishedScope).To(Equal("global"))
				Expect(p[0].TemplateSuffix).To(Equal(""))
				Expect(p[0].Title).To(Equal("IPod Touch 8GB"))
				Expect(p[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:00"))
				Expect(p[0].Vendor).To(Equal("Apple"))
				Expect(p[0].Tags).To(Equal(""))

				Expect(len(p[0].Variants)).To(Equal(1))

				Expect(p[0].Variants[0].Barcode).To(Equal("1234_black"))
				Expect(p[0].Variants[0].CompareAtPrice).To(Equal(""))
				Expect(p[0].Variants[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:00"))
				Expect(p[0].Variants[0].FulfillmentService).To(Equal("manual"))
				Expect(p[0].Variants[0].Grams).To(Equal(float64(200)))
				Expect(p[0].Variants[0].Id).To(Equal(int64(447654529)))
				Expect(p[0].Variants[0].InventoryManagement).To(Equal("shopify"))
				Expect(p[0].Variants[0].InventoryPolicy).To(Equal("continue"))
				Expect(p[0].Variants[0].Option1).To(Equal("Black"))
				Expect(p[0].Variants[0].Option2).To(Equal(""))
				Expect(p[0].Variants[0].Option3).To(Equal(""))
				Expect(p[0].Variants[0].Position).To(Equal(1))
				Expect(p[0].Variants[0].Price).To(Equal("199.00"))
				Expect(p[0].Variants[0].ProductId).To(Equal(int64(921728736)))
				Expect(p[0].Variants[0].RequiresShipping).To(BeTrue())
				Expect(p[0].Variants[0].Sku).To(Equal("IPOD2009BLACK"))
				Expect(p[0].Variants[0].Taxable).To(BeTrue())
				Expect(p[0].Variants[0].Title).To(Equal("Black"))
				Expect(p[0].Variants[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:00"))
				Expect(p[0].Variants[0].InventoryQuantity).To(Equal(int64(13)))
				Expect(p[0].Variants[0].OldInventoryQuantity).To(Equal(int64(13)))
				Expect(p[0].Variants[0].ImageId).To(Equal(int64(0)))
				Expect(p[0].Variants[0].Weight).To(Equal(0.2))
				Expect(p[0].Variants[0].WeightUnit).To(Equal("kg"))

				Expect(len(p[0].Options)).To(Equal(1))

				Expect(p[0].Options[0].Id).To(Equal(int64(891236591)))
				Expect(p[0].Options[0].Name).To(Equal("Title"))
				Expect(p[0].Options[0].Position).To(Equal(1))
				Expect(p[0].Options[0].ProductId).To(Equal(int64(921728736)))

				Expect(len(p[0].Images)).To(Equal(0))

				Expect(mockShopify.Hits()).To(Equal(1))
			})
		})

		g.Describe("Get One", func() {
			g.It("should get a single product", func() {
				mockShopify.SetPayload([]byte(SampleProductJson))
				mockShopify.SetStatus(http.StatusOK)
				host, port := mockShopify.HostPort()

				s := &Shopify{fmt.Sprintf("http://%s:%s", host, port)}
				c := &Credentials{"some-cart-hash", "oauthom"}

				p, err := s.GetProduct("632910392", c, nil)
				Expect(err).NotTo(HaveOccurred())
				Expect(p).NotTo(BeNil())

				Expect(p.BodyHtml).To(ContainSubstring("It's the small iPod with one very big idea"))
				Expect(p.CreatedAt).To(Equal("2015-03-28T13:31:19-04:01"))
				Expect(p.Handle).To(Equal("ipod-nano"))
				Expect(p.Id).To(Equal(int64(632910392)))
				Expect(p.ProductType).To(Equal("Cult Products"))
				Expect(p.PublishedAt).To(Equal("2007-12-31T19:00:00-05:00"))
				Expect(p.PublishedScope).To(Equal("web"))
				Expect(p.TemplateSuffix).To(Equal(""))
				Expect(p.Title).To(Equal("IPod Nano - 8GB"))
				Expect(p.UpdatedAt).To(Equal("2015-03-28T13:31:19-04:02"))
				Expect(p.Vendor).To(Equal("Apple"))
				Expect(p.Tags).To(Equal("Emotive, Flash Memory, MP3, Music"))

				Expect(len(p.Variants)).To(Equal(4))

				Expect(p.Variants[0].Barcode).To(Equal("1234_pink"))
				Expect(p.Variants[0].CompareAtPrice).To(Equal(""))
				Expect(p.Variants[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:03"))
				Expect(p.Variants[0].FulfillmentService).To(Equal("manual"))
				Expect(p.Variants[0].Grams).To(Equal(float64(200)))
				Expect(p.Variants[0].Id).To(Equal(int64(808950810)))
				Expect(p.Variants[0].InventoryManagement).To(Equal("shopify"))
				Expect(p.Variants[0].InventoryPolicy).To(Equal("continue"))
				Expect(p.Variants[0].Option1).To(Equal("Pink"))
				Expect(p.Variants[0].Option2).To(Equal(""))
				Expect(p.Variants[0].Option3).To(Equal(""))
				Expect(p.Variants[0].Position).To(Equal(1))
				Expect(p.Variants[0].Price).To(Equal("199.00"))
				Expect(p.Variants[0].ProductId).To(Equal(int64(632910392)))
				Expect(p.Variants[0].RequiresShipping).To(BeTrue())
				Expect(p.Variants[0].Sku).To(Equal("IPOD2008PINK"))
				Expect(p.Variants[0].Taxable).To(BeTrue())
				Expect(p.Variants[0].Title).To(Equal("Pink"))
				Expect(p.Variants[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:04"))
				Expect(p.Variants[0].InventoryQuantity).To(Equal(int64(10)))
				Expect(p.Variants[0].OldInventoryQuantity).To(Equal(int64(10)))
				Expect(p.Variants[0].ImageId).To(Equal(int64(562641783)))
				Expect(p.Variants[0].Weight).To(Equal(0.2))
				Expect(p.Variants[0].WeightUnit).To(Equal("kg"))

				Expect(p.Variants[1].Barcode).To(Equal("1234_red"))
				Expect(p.Variants[1].CompareAtPrice).To(Equal(""))
				Expect(p.Variants[1].CreatedAt).To(Equal("2015-03-28T13:31:19-04:05"))
				Expect(p.Variants[1].FulfillmentService).To(Equal("manual"))
				Expect(p.Variants[1].Grams).To(Equal(float64(200)))
				Expect(p.Variants[1].Id).To(Equal(int64(49148385)))
				Expect(p.Variants[1].InventoryManagement).To(Equal("shopify"))
				Expect(p.Variants[1].InventoryPolicy).To(Equal("continue"))
				Expect(p.Variants[1].Option1).To(Equal("Red"))
				Expect(p.Variants[1].Option2).To(Equal(""))
				Expect(p.Variants[1].Option3).To(Equal(""))
				Expect(p.Variants[1].Position).To(Equal(2))
				Expect(p.Variants[1].Price).To(Equal("199.00"))
				Expect(p.Variants[1].ProductId).To(Equal(int64(632910392)))
				Expect(p.Variants[1].RequiresShipping).To(BeTrue())
				Expect(p.Variants[1].Sku).To(Equal("IPOD2008RED"))
				Expect(p.Variants[1].Taxable).To(BeTrue())
				Expect(p.Variants[1].Title).To(Equal("Red"))
				Expect(p.Variants[1].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:06"))
				Expect(p.Variants[1].InventoryQuantity).To(Equal(int64(20)))
				Expect(p.Variants[1].OldInventoryQuantity).To(Equal(int64(20)))
				Expect(p.Variants[1].ImageId).To(Equal(int64(0)))
				Expect(p.Variants[1].Weight).To(Equal(0.2))
				Expect(p.Variants[1].WeightUnit).To(Equal("kg"))

				Expect(len(p.Options)).To(Equal(1))

				Expect(p.Options[0].Id).To(Equal(int64(594680422)))
				Expect(p.Options[0].Name).To(Equal("Title"))
				Expect(p.Options[0].Position).To(Equal(1))
				Expect(p.Options[0].ProductId).To(Equal(int64(632910392)))

				Expect(len(p.Images)).To(Equal(2))

				Expect(p.Images[0].CreatedAt).To(Equal("2015-03-28T13:31:19-04:07"))
				Expect(p.Images[0].Id).To(Equal(int64(850703190)))
				Expect(p.Images[0].Position).To(Equal(1))
				Expect(p.Images[0].ProductId).To(Equal(int64(632910392)))
				Expect(p.Images[0].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:08"))
				Expect(p.Images[0].Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1427563879"))
				Expect(len(p.Images[0].VariantIds)).To(Equal(0))

				Expect(p.Images[1].CreatedAt).To(Equal("2015-03-28T13:31:19-04:09"))
				Expect(p.Images[1].Id).To(Equal(int64(562641783)))
				Expect(p.Images[1].Position).To(Equal(2))
				Expect(p.Images[1].ProductId).To(Equal(int64(632910392)))
				Expect(p.Images[1].UpdatedAt).To(Equal("2015-03-28T13:31:19-04:10"))
				Expect(p.Images[1].Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano-2.png?v=1427563879"))
				Expect(p.Images[1].VariantIds[0]).To(Equal(int64(808950810)))

				Expect(p.Image.CreatedAt).To(Equal("2015-03-28T13:31:19-04:11"))
				Expect(p.Image.Id).To(Equal(int64(850703190)))
				Expect(p.Image.Position).To(Equal(1))
				Expect(p.Image.ProductId).To(Equal(int64(632910392)))
				Expect(p.Image.UpdatedAt).To(Equal("2015-03-28T13:31:19-04:12"))
				Expect(p.Image.Source).To(Equal("https://cdn.shopify.com/s/files/1/0006/9093/3842/products/ipod-nano.png?v=1427563879"))
				Expect(len(p.Image.VariantIds)).To(Equal(0))
			})
		})

		g.Describe("Count", func() {
			g.It("should get a products count", func() {
				mockShopify.SetPayload([]byte(SampleProductsCountJson))
				mockShopify.SetStatus(http.StatusOK)
				host, port := mockShopify.HostPort()

				s := &Shopify{fmt.Sprintf("http://%s:%s", host, port)}
				c := &Credentials{"some-cart-hash", "oauthom"}

				count, err := s.GetProductsCount(c, nil)
				Expect(err).NotTo(HaveOccurred())
				Expect(count.Count).To(Equal(int64(20)))
			})

			g.It("should get a products count that belong to a certain collection", func() {
				mockShopify.SetPayload([]byte(SampleProductsCountCollectionJson))
				mockShopify.SetStatus(http.StatusOK)
				host, port := mockShopify.HostPort()

				s := &Shopify{fmt.Sprintf("http://%s:%s", host, port)}
				c := &Credentials{"some-cart-hash", "oauthom"}
				params := url.Values{}
				params.Add("collection_id", "841564295")

				count, err := s.GetProductsCount(c, params)
				Expect(err).NotTo(HaveOccurred())
				Expect(count.Count).To(Equal(int64(1)))
			})
		})
	})
}