本文整理汇总了Golang中github.com/maximilien/softlayer-go/test_helpers.ReadJsonTestFixtures函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadJsonTestFixtures函数的具体用法?Golang ReadJsonTestFixtures怎么用?Golang ReadJsonTestFixtures使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadJsonTestFixtures函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetItemsByType
func (fps *FakeProductPackageService) GetItemsByType(packageType string) ([]datatypes.SoftLayer_Product_Item, error) {
response, _ := testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Product_Package_getItemsByType_virtual_server.json")
productItems := []datatypes.SoftLayer_Product_Item{}
json.Unmarshal(response, &productItems)
return productItems, nil
}
示例2:
networkStorageAllowedHostService, err = fakeClient.GetSoftLayer_Network_Storage_Allowed_Host_Service()
Expect(err).ToNot(HaveOccurred())
Expect(networkStorageAllowedHostService).ToNot(BeNil())
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := networkStorageAllowedHostService.GetName()
Expect(name).To(Equal("SoftLayer_Network_Storage_Allowed_Host"))
})
})
Context("#GetCredential", func() {
BeforeEach(func() {
fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Network_Storage_Allowed_Host_Service_getCredential.json")
Expect(err).ToNot(HaveOccurred())
})
It("return the credential with allowed host id", func() {
credential, err := networkStorageAllowedHostService.GetCredential(123456)
Expect(err).NotTo(HaveOccurred())
Expect(credential).ToNot(BeNil())
Expect(credential.Username).To(Equal("fake-username"))
Expect(credential.Password).To(Equal("fake-password"))
})
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 {
示例3:
Expect(err).ToNot(HaveOccurred())
Expect(virtualDiskImageService).ToNot(BeNil())
virtualDiskImage = datatypes.SoftLayer_Virtual_Disk_Image{}
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := virtualDiskImageService.GetName()
Expect(name).To(Equal("SoftLayer_Virtual_Disk_Image"))
})
})
Context("#GetObject", func() {
BeforeEach(func() {
fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Virtual_Disk_Image_Service_getObject.json")
Expect(err).ToNot(HaveOccurred())
})
It("gets the SoftLayer_Virtual_Disk_Image instance", func() {
virtualDiskImage, err = virtualDiskImageService.GetObject(4868344)
Expect(err).ToNot(HaveOccurred())
Expect(virtualDiskImage.Capacity).To(Equal(25))
Expect(virtualDiskImage.CreateDate).ToNot(BeNil())
Expect(virtualDiskImage.Description).To(Equal("yz-fabric-node-20140407-133340-856.softlayer.com"))
Expect(virtualDiskImage.Id).To(Equal(4868344))
Expect(virtualDiskImage.ModifyDate).To(BeNil())
Expect(virtualDiskImage.Name).To(Equal("yz-fabric-node-20140407-133340-856.softlayer.com"))
Expect(virtualDiskImage.ParentId).To(Equal(0))
Expect(virtualDiskImage.StorageRepositoryId).To(Equal(1105002))
Expect(virtualDiskImage.TypeId).To(Equal(241))
示例4:
productPackageService, err = fakeClient.GetSoftLayer_Product_Package_Service()
Expect(err).ToNot(HaveOccurred())
Expect(productPackageService).ToNot(BeNil())
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := productPackageService.GetName()
Expect(name).To(Equal("SoftLayer_Product_Package"))
})
})
Context("#GetItemPrices", func() {
BeforeEach(func() {
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Product_Package_getItemPrices.json")
Expect(err).ToNot(HaveOccurred())
})
It("returns an array of datatypes.SoftLayer_Product_Item_Price", func() {
itemPrices, err := productPackageService.GetItemPrices(0)
Expect(err).ToNot(HaveOccurred())
Expect(len(itemPrices)).To(Equal(1))
Expect(itemPrices[0].Id).To(Equal(123))
Expect(itemPrices[0].Item.Id).To(Equal(456))
})
})
Context("#GetItemPricesBySize", func() {
BeforeEach(func() {
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Product_Package_getItemPrices.json")
示例5:
Expect(virtualGuestService).ToNot(BeNil())
virtualGuest = datatypes.SoftLayer_Virtual_Guest{}
virtualGuestTemplate = datatypes.SoftLayer_Virtual_Guest_Template{}
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := virtualGuestService.GetName()
Expect(name).To(Equal("SoftLayer_Virtual_Guest"))
})
})
Context("#CreateObject", func() {
BeforeEach(func() {
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Virtual_Guest_Service_createObject.json")
Expect(err).ToNot(HaveOccurred())
})
It("creates a new SoftLayer_Virtual_Guest instance", func() {
virtualGuestTemplate = datatypes.SoftLayer_Virtual_Guest_Template{
Hostname: "fake-hostname",
Domain: "fake.domain.com",
StartCpus: 2,
MaxMemory: 1024,
Datacenter: datatypes.Datacenter{
Name: "fake-datacenter-name",
},
HourlyBillingFlag: true,
LocalDiskFlag: false,
DedicatedAccountHostOnlyFlag: false,
示例6:
productOrderService, err = fakeClient.GetSoftLayer_Product_Order_Service()
Expect(err).ToNot(HaveOccurred())
Expect(productOrderService).ToNot(BeNil())
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := productOrderService.GetName()
Expect(name).To(Equal("SoftLayer_Product_Order"))
})
})
Context("#PlaceOrder", func() {
BeforeEach(func() {
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Product_Order_placeOrder.json")
Expect(err).ToNot(HaveOccurred())
})
It("returns an instance of datatypes.SoftLayer_Container_Product_Order_Receipt", func() {
receipt, err := productOrderService.PlaceOrder(datatypes.SoftLayer_Container_Product_Order{})
Expect(err).ToNot(HaveOccurred())
Expect(receipt).ToNot(BeNil())
Expect(receipt.OrderId).To(Equal(123))
})
})
Context("#PlaceContainerOrderNetworkPerformanceStorageIscsi", func() {
BeforeEach(func() {
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Product_Order_placeOrder.json")
Expect(err).ToNot(HaveOccurred())
示例7:
Expect(vgbdtgService).ToNot(BeNil())
vgbdtGroup = datatypes.SoftLayer_Virtual_Guest_Block_Device_Template_Group{}
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := vgbdtgService.GetName()
Expect(name).To(Equal("SoftLayer_Virtual_Guest_Block_Device_Template_Group"))
})
})
Context("#GetObject", func() {
BeforeEach(func() {
vgbdtGroup.Id = 200150
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Virtual_Guest_Block_Device_Template_Group_Service_getObject.json")
Expect(err).ToNot(HaveOccurred())
})
It("sucessfully retrieves SoftLayer_Virtual_Guest_Block_Device_Template_Group instance", func() {
vgbdtg, err := vgbdtgService.GetObject(vgbdtGroup.Id)
Expect(err).ToNot(HaveOccurred())
Expect(vgbdtg.AccountId).To(Equal(278444))
Expect(vgbdtg.CreateDate).ToNot(BeNil())
Expect(vgbdtg.Id).To(Equal(vgbdtGroup.Id))
Expect(vgbdtg.Name).To(Equal("BOSH-eCPI-packer-centos-2014-08-12T15:54:16Z"))
Expect(vgbdtg.Note).To(Equal("centos image created by packer at 2014-08-12T15:54:16Z"))
Expect(vgbdtg.ParentId).To(BeNil())
Expect(vgbdtg.PublicFlag).To(Equal(0))
Expect(vgbdtg.StatusId).To(Equal(1))
Expect(vgbdtg.Summary).To(Equal("centos image created by packer at 2014-08-12T15:54:16Z"))
开发者ID:jerrygb,项目名称:softlayer-go,代码行数:31,代码来源:softLayer_virtual_guest_block_device_template_group_test.go
示例8:
Expect(err).ToNot(HaveOccurred())
Expect(dnsDomainResourceRecordService).ToNot(BeNil())
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := dnsDomainResourceRecordService.GetName()
Expect(name).To(Equal("SoftLayer_Dns_Domain_ResourceRecord"))
})
})
Context("#CreateObject", func() {
var template datatypes.SoftLayer_Dns_Domain_ResourceRecord_Template
BeforeEach(func() {
fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Dns_Domain_ResourceRecord_Service_createObject.json")
Expect(err).ToNot(HaveOccurred())
template = datatypes.SoftLayer_Dns_Domain_ResourceRecord_Template{
Data: "testData",
DomainId: 123,
Expire: 99999,
Host: "testHost.com",
Id: 111,
Minimum: 1,
MxPriority: 9,
Refresh: 100,
ResponsiblePerson: "someTestPerson",
Retry: 444,
Ttl: 222,
Type: "someTestType",
示例9:
billingItemCancellationRequestService, err = fakeClient.GetSoftLayer_Billing_Item_Cancellation_Request_Service()
Expect(err).ToNot(HaveOccurred())
Expect(billingItemCancellationRequestService).ToNot(BeNil())
})
Context("#GetNam", func() {
It("returns the name for the service", func() {
name := billingItemCancellationRequestService.GetName()
Expect(name).To(Equal("SoftLayer_Billing_Item_Cancellation_Request"))
})
})
Context("#CreateObject", func() {
BeforeEach(func() {
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Billing_Item_Cancellation_Request_Service_createObject.json")
Expect(err).ToNot(HaveOccurred())
})
It("returns an instance of datatypes.SoftLayer_Network_Storage", func() {
request := datatypes.SoftLayer_Billing_Item_Cancellation_Request{}
result, err := billingItemCancellationRequestService.CreateObject(request)
Expect(err).ToNot(HaveOccurred())
Expect(result.Id).To(Equal(123))
Expect(result.AccountId).To(Equal(456))
Expect(result.TicketId).To(Equal(789))
})
})
})
开发者ID:digideskweb,项目名称:bosh-softlayer-cpi,代码行数:30,代码来源:softlayer_billing_item_cancellation_request_test.go
示例10:
Expect(err).ToNot(HaveOccurred())
Expect(hardwareService).ToNot(BeNil())
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := hardwareService.GetName()
Expect(name).To(Equal("SoftLayer_Hardware"))
})
})
Context("#CreateObject", func() {
var template datatypes.SoftLayer_Hardware_Template
BeforeEach(func() {
fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Hardware_Service_createObject.json")
Expect(err).ToNot(HaveOccurred())
template = datatypes.SoftLayer_Hardware_Template{
Hostname: "softlayer",
Domain: "testing.com",
ProcessorCoreAmount: 2,
MemoryCapacity: 2,
HourlyBillingFlag: true,
OperatingSystemReferenceCode: "UBUNTU_LATEST",
Datacenter: &datatypes.Datacenter{
Name: "ams01",
},
}
})
示例11:
volume = datatypes.SoftLayer_Network_Storage{}
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := hardwareService.GetName()
Expect(name).To(Equal("SoftLayer_Hardware"))
})
})
Context("#CreateObject", func() {
var template datatypes.SoftLayer_Hardware_Template
BeforeEach(func() {
fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Hardware_Service_createObject.json")
Expect(err).ToNot(HaveOccurred())
template = datatypes.SoftLayer_Hardware_Template{
Hostname: "softlayer",
Domain: "testing.com",
ProcessorCoreAmount: 2,
MemoryCapacity: 2,
HourlyBillingFlag: true,
OperatingSystemReferenceCode: "UBUNTU_LATEST",
Datacenter: &datatypes.Datacenter{
Name: "ams01",
},
}
})
示例12:
Expect(sshKeyService).ToNot(BeNil())
sshKey = datatypes.SoftLayer_Security_Ssh_Key{}
sshKeyTemplate = datatypes.SoftLayer_Security_Ssh_Key{}
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := sshKeyService.GetName()
Expect(name).To(Equal("SoftLayer_Security_Ssh_Key"))
})
})
Context("#CreateObject", func() {
BeforeEach(func() {
fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Security_Ssh_Key_Service_createObject.json")
Expect(err).ToNot(HaveOccurred())
})
It("creates a new SoftLayer_Ssh_Key instance", func() {
sshKeyTemplate = datatypes.SoftLayer_Security_Ssh_Key{
Fingerprint: "fake-fingerprint",
Key: "fake-key",
Label: "fake-label",
Notes: "fake-notes",
}
sshKey, err = sshKeyService.CreateObject(sshKeyTemplate)
Expect(err).ToNot(HaveOccurred())
Expect(sshKey.Fingerprint).To(Equal("fake-fingerprint"))
Expect(sshKey.Key).To(Equal("fake-key"))
Expect(sshKey.Label).To(Equal("fake-label"))
示例13:
dnsDomainService, err = fakeClient.GetSoftLayer_Dns_Domain_Service()
Expect(err).ToNot(HaveOccurred())
Expect(dnsDomainService).NotTo(BeNil())
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := dnsDomainService.GetName()
Expect(name).To(Equal("SoftLayer_Dns_Domain"))
})
})
Context("#CreateDns", func() {
BeforeEach(func() {
fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Dns_Domain_createObject.json")
Expect(err).ToNot(HaveOccurred())
})
It("returns an instance of datatypes.SoftLayer_Dns_Domain", func() {
dns, err := dnsDomainService.CreateObject(datatypes.SoftLayer_Dns_Domain_Template{})
Expect(err).ToNot(HaveOccurred())
Expect(dns).NotTo(BeNil())
Expect(dns.Id).NotTo(BeNil())
Expect(dns.Serial).NotTo(BeNil())
Expect(dns.UpdateDate).NotTo(BeNil())
Expect(dns.Name).To(Equal("qwerty123ff.com"))
})
Context("when HTTP client returns error codes 40x or 50x", func() {
It("fails for error code 40x", func() {
示例14:
networkStorageService, err = fakeClient.GetSoftLayer_Network_Storage_Service()
Expect(err).ToNot(HaveOccurred())
Expect(networkStorageService).ToNot(BeNil())
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := networkStorageService.GetName()
Expect(name).To(Equal("SoftLayer_Network_Storage"))
})
})
Context("#CreateIscsiVolume", func() {
BeforeEach(func() {
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Network_Storage_Service_getIscsiVolume.json")
Expect(err).ToNot(HaveOccurred())
})
It("fails with error if the volume size is negative", func() {
_, err := networkStorageService.CreateIscsiVolume(-1, "fake-location")
Expect(err).To(HaveOccurred())
})
})
Context("#GetIscsiVolume", func() {
BeforeEach(func() {
fakeClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Network_Storage_Service_getIscsiVolume.json")
Expect(err).ToNot(HaveOccurred())
})
It("returns the iSCSI volume object based on volume id", func() {
示例15:
LongName: "Location 2",
},
}
})
Context("#GetName", func() {
It("returns the name for the service", func() {
name := vgbdtgService.GetName()
Expect(name).To(Equal("SoftLayer_Virtual_Guest_Block_Device_Template_Group"))
})
})
Context("#GetObject", func() {
BeforeEach(func() {
vgbdtGroup.Id = 200150
fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Virtual_Guest_Block_Device_Template_Group_Service_getObject.json")
Expect(err).ToNot(HaveOccurred())
})
It("sucessfully retrieves SoftLayer_Virtual_Guest_Block_Device_Template_Group instance", func() {
vgbdtg, err := vgbdtgService.GetObject(vgbdtGroup.Id)
Expect(err).ToNot(HaveOccurred())
Expect(vgbdtg.AccountId).To(Equal(278444))
Expect(vgbdtg.CreateDate).ToNot(BeNil())
Expect(vgbdtg.Id).To(Equal(vgbdtGroup.Id))
Expect(vgbdtg.Name).To(Equal("BOSH-eCPI-packer-centos-2014-08-12T15:54:16Z"))
Expect(vgbdtg.Note).To(Equal("centos image created by packer at 2014-08-12T15:54:16Z"))
Expect(vgbdtg.ParentId).To(BeNil())
Expect(vgbdtg.PublicFlag).To(Equal(0))
Expect(vgbdtg.StatusId).To(Equal(1))
Expect(vgbdtg.Summary).To(Equal("centos image created by packer at 2014-08-12T15:54:16Z"))
开发者ID:TheWeatherCompany,项目名称:softlayer-go,代码行数:31,代码来源:softLayer_virtual_guest_block_device_template_group_test.go