本文整理汇总了Golang中github.com/maximilien/softlayer-go/client/fakes.FakeSoftLayerClient.DoRawHttpRequestResponses方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeSoftLayerClient.DoRawHttpRequestResponses方法的具体用法?Golang FakeSoftLayerClient.DoRawHttpRequestResponses怎么用?Golang FakeSoftLayerClient.DoRawHttpRequestResponses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/maximilien/softlayer-go/client/fakes.FakeSoftLayerClient
的用法示例。
在下文中一共展示了FakeSoftLayerClient.DoRawHttpRequestResponses方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetTestFixturesForFakeSoftLayerClient
func SetTestFixturesForFakeSoftLayerClient(fakeSoftLayerClient *fakesslclient.FakeSoftLayerClient, fileNames []string) {
workingDir, err := os.Getwd()
Expect(err).ToNot(HaveOccurred())
for _, fileName := range fileNames {
fileContents, err := ReadJsonTestFixtures(filepath.Join(workingDir, "..", ".."), "softlayer", fileName)
Expect(err).ToNot(HaveOccurred())
fakeSoftLayerClient.DoRawHttpRequestResponses = append(fakeSoftLayerClient.DoRawHttpRequestResponses, fileContents)
}
}
示例2: readJsonTestFixtures
func readJsonTestFixtures(fakeClient *slclientfakes.FakeSoftLayerClient) {
blockDeviceTemplateGroups, err := common.ReadJsonTestFixtures("services", "SoftLayer_Account_Service_getBlockDeviceTemplateGroups.json")
Expect(err).ToNot(HaveOccurred())
getObject, err := common.ReadJsonTestFixtures("services", "SoftLayer_Virtual_Guest_Block_Device_Template_Group_Service_getObject.json")
Expect(err).ToNot(HaveOccurred())
getDatacenters, err := common.ReadJsonTestFixtures("services", "SoftLayer_Virtual_Guest_Block_Device_Template_Group_Service_getDatacenters.json")
Expect(err).ToNot(HaveOccurred())
fakeClient.DoRawHttpRequestResponses = [][]byte{blockDeviceTemplateGroups, getObject, getDatacenters}
}
示例3:
})
It("returns an array of datatypes.SoftLayer_Product_Item", func() {
productItems, err := productPackageService.GetItems(222)
Expect(err).ToNot(HaveOccurred())
Expect(len(productItems)).To(Equal(2))
Expect(productItems[0].Id).To(Equal(123))
Expect(productItems[0].Prices[0].Id).To(Equal(456))
})
})
Context("#GetItemsByType", func() {
BeforeEach(func() {
response, err := testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Product_Package_getAllObjects_virtual_server.json")
fakeClient.DoRawHttpRequestResponses = append(fakeClient.DoRawHttpRequestResponses, response)
Expect(err).ToNot(HaveOccurred())
})
It("returns an array of datatypes.SoftLayer_Product_Item", func() {
response, err := testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Product_Package_getItems.json")
fakeClient.DoRawHttpRequestResponses = append(fakeClient.DoRawHttpRequestResponses, response)
productItems, err := productPackageService.GetItemsByType("VIRTUAL_SERVER_INSTANCE")
Expect(err).ToNot(HaveOccurred())
Expect(len(productItems)).To(Equal(2))
Expect(productItems[0].Id).To(Equal(123))
Expect(productItems[0].Prices[0].Id).To(Equal(456))
})
})