• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang test_helpers.ReadJsonTestFixtures函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/maximilien/softlayer-go/test_helpers.ReadJsonTestFixtures函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadJsonTestFixtures函数的具体用法?Golang ReadJsonTestFixtures怎么用?Golang ReadJsonTestFixtures使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ReadJsonTestFixtures函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:mattcui,项目名称:softlayer-go,代码行数:8,代码来源:fake_softlayer_product_package.go


示例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 {
开发者ID:jianqiu,项目名称:bosh-softlayer-cpi,代码行数:30,代码来源:softlayer_network_storage_allowed_host_test.go


示例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))
开发者ID:jianqiu,项目名称:bosh-softlayer-cpi,代码行数:31,代码来源:softlayer_virtual_disk_image_test.go


示例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")
开发者ID:cheyang,项目名称:softlayer-go,代码行数:30,代码来源:softlayer_product_package_test.go


示例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,
开发者ID:cheyang,项目名称:softlayer-go,代码行数:31,代码来源:softlayer_virtual_guest_test.go


示例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())
开发者ID:digideskweb,项目名称:bosh-softlayer-cpi,代码行数:30,代码来源:softlayer_product_order_test.go


示例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",
开发者ID:jianqiu,项目名称:bosh-softlayer-cpi,代码行数:31,代码来源:softlayer_dns_domain_resource_record_test.go


示例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",
				},
			}
		})
开发者ID:jianqiu,项目名称:bosh-softlayer-cpi,代码行数:30,代码来源:softlayer_hardware_test.go


示例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",
				},
			}
		})
开发者ID:TheWeatherCompany,项目名称:softlayer-go,代码行数:29,代码来源:softlayer_hardware_test.go


示例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"))
开发者ID:jianqiu,项目名称:bosh-softlayer-cpi,代码行数:31,代码来源:softlayer_security_ssh_key_test.go


示例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() {
开发者ID:mattcui,项目名称:softlayer-go,代码行数:30,代码来源:softlayer_dns_domain_test.go


示例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() {
开发者ID:ardnaxelarak,项目名称:softlayer-go,代码行数:30,代码来源:softlayer_network_storage_test.go


示例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


示例16:

		accountService, err = fakeClient.GetSoftLayer_Account_Service()
		Expect(err).ToNot(HaveOccurred())
		Expect(accountService).ToNot(BeNil())
	})

	Context("#GetName", func() {
		It("returns the name for the service", func() {
			name := accountService.GetName()
			Expect(name).To(Equal("SoftLayer_Account"))
		})
	})

	Context("#GetAccountStatus", func() {
		BeforeEach(func() {
			fakeClient.FakeHttpClient.DoRawHttpRequestResponse, err = testhelpers.ReadJsonTestFixtures("services", "SoftLayer_Account_Service_getAccountStatus.json")
			Expect(err).ToNot(HaveOccurred())
		})

		It("returns an instance of datatypes.SoftLayer_Account_Status that is Active", func() {
			accountStatus, err := accountService.GetAccountStatus()
			Expect(err).ToNot(HaveOccurred())
			Expect(accountStatus.Id).ToNot(Equal(0))
			Expect(accountStatus.Name).To(Equal("Active"))
		})

		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
开发者ID:TheWeatherCompany,项目名称:softlayer-go,代码行数:30,代码来源:softlayer_account_test.go



注:本文中的github.com/maximilien/softlayer-go/test_helpers.ReadJsonTestFixtures函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap