Example #1
0
		dnsDomainService, err = testhelpers.CreateDnsDomainService()
		Expect(err).ToNot(HaveOccurred())

		testhelpers.TIMEOUT = 30 * time.Second
		testhelpers.POLLING_INTERVAL = 10 * time.Second
	})

	Context("SoftLayer_Dns_Domain", func() {
		It("creates a DNS Domain, update it, and delete it", func() {
			createdDnsDomain := testhelpers.CreateTestDnsDomain("test.domain.name")

			testhelpers.WaitForCreatedDnsDomainToBePresent(createdDnsDomain.Id)

			result, err := dnsDomainService.GetObject(createdDnsDomain.Id)
			Expect(err).ToNot(HaveOccurred())

			Expect(result.Name).To(Equal("test.domain.name"))

			dnsDomains, err := dnsDomainService.GetByDomainName("test.domain.name")
			Expect(err).ToNot(HaveOccurred())
			Expect(len(dnsDomains)).To(BeNumerically(">", 0))

			deleted, err := dnsDomainService.DeleteObject(createdDnsDomain.Id)
			Expect(err).ToNot(HaveOccurred())
			Expect(deleted).To(BeTrue())

			testhelpers.WaitForDeletedDnsDomainToNoLongerBePresent(createdDnsDomain.Id)
		})
	})
})
					_, err := dnsDomainService.CreateObject(datatypes.SoftLayer_Dns_Domain_Template{})
					Expect(err).To(HaveOccurred())
				}
			})
		})
	})

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

		It("returns an array of datatypes.SoftLayer_Dns_Domain", func() {
			dnsDomains, err := dnsDomainService.GetByDomainName("services.dal.bluemix.net")
			Expect(err).ToNot(HaveOccurred())
			Expect(dnsDomains).NotTo(BeNil())
			Expect(len(dnsDomains)).To(BeNumerically(">", 0))
			Expect(dnsDomains[0].Name).To(Equal("services.dal.bluemix.net"))
		})

		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

					_, err := dnsDomainService.GetByDomainName("services.dal.bluemix.net")
					Expect(err).To(HaveOccurred())
				}