當前位置: 首頁>>代碼示例>>Golang>>正文


Golang test_helpers.ReadJsonTestFixtures函數代碼示例

本文整理匯總了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
}
開發者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


注:本文中的github.com/maximilien/softlayer-go/test_helpers.ReadJsonTestFixtures函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。