_, err := hardwareService.GetDatacenter(1234567) Expect(err).To(HaveOccurred()) } }) }) }) Context("#GetPrimaryIpAddress", func() { BeforeEach(func() { fakeClient.FakeHttpClient.DoRawHttpRequestResponse = []byte("159.99.99.99") Expect(err).ToNot(HaveOccurred()) }) It("sucessfully retrieves Primary IP Address", func() { hdPrimaryIpAddress, err := hardwareService.GetPrimaryIpAddress(1234567) Expect(err).ToNot(HaveOccurred()) Expect(hdPrimaryIpAddress).To(Equal("159.99.99.99")) }) Context("when HTTP client returns error codes 40x or 50x", func() { It("fails for error code 40x", func() { errorCodes := []int{400, 401, 499} for _, errorCode := range errorCodes { fakeClient.FakeHttpClient.DoRawHttpRequestInt = errorCode _, err := hardwareService.GetPrimaryIpAddress(1234567) Expect(err).To(HaveOccurred()) } })