Пример #1
0
			Expect(got).Should(Equal(false))
			Expect(err).Should(HaveOccurred())
			Expect(err).Should(MatchError(plugin.EndpointDataTypeMismatchError{Key: "stringVal", DesiredType: "boolean"}))
		})
		It("errors out when pointed at a nonexistant key", func() {
			got, err := endpoint.BooleanValue("doesnotexist")
			Expect(got).Should(Equal(false))
			Expect(err).Should(HaveOccurred())
			Expect(err).Should(MatchError(plugin.EndpointMissingRequiredDataError{Key: "doesnotexist"}))
		})
	})
	Describe("FloatVal", func() {
		It("returns a float from the endpoint, when provided the right key", func() {
			expected := 1234.1234

			got, err := endpoint.FloatValue("floatVal")
			Expect(got).Should(BeEquivalentTo(expected))
			Expect(err).ShouldNot(HaveOccurred())
		})
		It("errors out when not pointed at an number", func() {
			got, err := endpoint.FloatValue("stringVal")
			Expect(got).Should(Equal(0.0))
			Expect(err).Should(HaveOccurred())
			Expect(err).Should(MatchError(plugin.EndpointDataTypeMismatchError{Key: "stringVal", DesiredType: "numeric"}))
		})
		It("errors out when pointed at a nonexistant key", func() {
			got, err := endpoint.FloatValue("doesnotexist")
			Expect(got).Should(Equal(0.0))
			Expect(err).Should(HaveOccurred())
			Expect(err).Should(MatchError(plugin.EndpointMissingRequiredDataError{Key: "doesnotexist"}))
		})