testMediaType = MediaType("application/test", func() { Attribute("foo", fooMediaType) Attribute("bar", barMediaType) Attribute("baz", bazMediaType) Links(func() { Link("foo") Link("baz", "bazLink") }) }) Ω(Errors).ShouldNot(HaveOccurred()) RunDSL() Ω(Errors).ShouldNot(HaveOccurred()) }) JustBeforeEach(func() { marshaler = codegen.MediaTypeMarshaler(testMediaType, false, "", context, source, target, "") marshalerImpl = codegen.MediaTypeMarshalerImpl(testMediaType, false, "", "default") }) It("generates the marshaler code", func() { Ω(marshaler).Should(Equal(mtMarshaled)) Ω(marshalerImpl).Should(Equal(mtMarshaledImpl)) }) }) Context("with a collection media type", func() { var collectionMediaType *MediaTypeDefinition var marshalerImpl string BeforeEach(func() { Design = nil
}) testMediaType = MediaType("test", func() { Attribute("foo", fooMediaType) Attribute("bar", barMediaType) Attribute("baz", bazMediaType) Links(func() { Link("foo") Link("baz", "bazLink") }) }) RunDSL() Ω(Errors).ShouldNot(HaveOccurred()) }) JustBeforeEach(func() { marshaler = codegen.MediaTypeMarshaler(testMediaType, context, source, target, "") }) It("generates the marshaler code", func() { Ω(marshaler).Should(Equal(mtMarshaled)) }) }) }) }) const ( arrayMarshaled = ` tmp1 := make([]int, len(raw)) for i, r := range raw { tmp1[i] = r } p = tmp1`