Expect(got).Should(BeNil()) Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(plugin.EndpointDataTypeMismatchError{Key: "stringVal", DesiredType: "array"})) }) It("errors out when pointed at a nonexistant key", func() { got, err := endpoint.ArrayValue("doesnotexist") Expect(got).Should(BeNil()) Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(plugin.EndpointMissingRequiredDataError{Key: "doesnotexist"})) }) }) Describe("MapVal", func() { It("returns a map from the endpoint, when provided the right key", func() { expected := map[string]interface{}{"key": "value"} got, err := endpoint.MapValue("mapVal") Expect(got).Should(BeEquivalentTo(expected)) Expect(err).ShouldNot(HaveOccurred()) }) It("errors out when not pointed at a map", func() { got, err := endpoint.MapValue("stringVal") Expect(got).Should(BeNil()) Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(plugin.EndpointDataTypeMismatchError{Key: "stringVal", DesiredType: "map"})) }) It("errors out when pointed at a nonexistant key", func() { got, err := endpoint.MapValue("doesnotexist") Expect(got).Should(BeNil()) Expect(err).Should(HaveOccurred()) Expect(err).Should(MatchError(plugin.EndpointMissingRequiredDataError{Key: "doesnotexist"})) })