for _, errorCode := range errorCodes { fakeClient.FakeHttpClient.DoRawHttpRequestInt = errorCode fakeClient.FakeHttpClient.DoRawHttpRequestResponse = []byte("false") _, err := hardwareService.PowerOff(1234567) Expect(err).To(HaveOccurred()) } }) }) }) Context("#PowerOffSoft", func() { It("sucessfully power off soft hardware instance", func() { fakeClient.FakeHttpClient.DoRawHttpRequestResponse = []byte("true") rebooted, err := hardwareService.PowerOffSoft(1234567) Expect(err).ToNot(HaveOccurred()) Expect(rebooted).To(BeTrue()) }) It("fails to power off soft hardware instance", func() { fakeClient.FakeHttpClient.DoRawHttpRequestResponse = []byte("false") rebooted, err := hardwareService.PowerOffSoft(1234567) Expect(err).To(HaveOccurred()) Expect(rebooted).To(BeFalse()) }) Context("when HTTP client returns error codes 40x or 50x", func() { It("fails for error code 40x", func() { errorCodes := []int{400, 401, 499}