func (f SoftLayerFinder) findInVirtualGuestDeviceTemplateGroups(uuid string, accountService sl.SoftLayer_Account_Service) (Stemcell, bool, error) { filters := fmt.Sprintf(`{"blockDeviceTemplateGroups":{"globalIdentifier":{"operation":"%s"}}}`, uuid) vgdtgGroups, err := accountService.GetBlockDeviceTemplateGroupsWithFilter(filters) if err != nil { return nil, false, bosherr.WrapError(err, "Getting virtual guest device template groups") } for _, vgdtgGroup := range vgdtgGroups { if vgdtgGroup.GlobalIdentifier == uuid { return NewSoftLayerStemcell(vgdtgGroup.Id, vgdtgGroup.GlobalIdentifier, VirtualGuestDeviceTemplateGroupKind, f.client, f.logger), true, nil } } return nil, false, nil }
_, err := accountService.GetBlockDeviceTemplateGroups() Expect(err).To(HaveOccurred()) } }) }) }) Context("#GetBlockDeviceTemplateGroupsWithFilter", func() { BeforeEach(func() { fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Account_Service_getBlockDeviceTemplateGroups.json") Expect(err).ToNot(HaveOccurred()) }) It("returns an array of datatypes.SoftLayer_Virtual_Guest_Block_Device_Template_Group", func() { groups, err := accountService.GetBlockDeviceTemplateGroupsWithFilter(`{"correct-filter":"whatever"}`) Expect(err).ToNot(HaveOccurred()) Expect(groups).ToNot(BeNil()) }) It("returns an error due to failed Json validation", func() { _, err := accountService.GetBlockDeviceTemplateGroupsWithFilter(`{{"wrong-filter":"whatever"}`) Expect(err).To(HaveOccurred()) }) 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