github.com/zak-blake/goa@v1.4.1/design/apidsl/test/runner_test.go (about) 1 package test 2 3 import ( 4 . "github.com/goadesign/goa/design" 5 . "github.com/goadesign/goa/design/apidsl" 6 "github.com/goadesign/goa/dslengine" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 ) 10 11 // Global test definitions 12 const apiName = "API" 13 const apiDescription = "API description" 14 const resourceName = "R" 15 const resourceDescription = "R description" 16 const typeName = "T" 17 const typeDescription = "T description" 18 const mediaTypeIdentifier = "mt/json" 19 const mediaTypeDescription = "MT description" 20 21 var _ = API(apiName, func() { 22 Description(apiDescription) 23 }) 24 25 var _ = Resource(resourceName, func() { 26 Description(resourceDescription) 27 }) 28 29 var _ = Type(typeName, func() { 30 Description(typeDescription) 31 Attribute("bar") 32 }) 33 34 var _ = MediaType(mediaTypeIdentifier, func() { 35 Description(mediaTypeDescription) 36 Attributes(func() { Attribute("foo") }) 37 View("default", func() { Attribute("foo") }) 38 }) 39 40 func init() { 41 dslengine.Run() 42 43 var _ = Describe("DSL execution", func() { 44 Context("with global DSL definitions", func() { 45 It("runs the DSL", func() { 46 Ω(dslengine.Errors).Should(BeEmpty()) 47 48 Ω(Design).ShouldNot(BeNil()) 49 Ω(Design.Name).Should(Equal(apiName)) 50 Ω(Design.Description).Should(Equal(apiDescription)) 51 52 Ω(Design.Resources).Should(HaveKey(resourceName)) 53 Ω(Design.Resources[resourceName]).ShouldNot(BeNil()) 54 Ω(Design.Resources[resourceName].Name).Should(Equal(resourceName)) 55 Ω(Design.Resources[resourceName].Description).Should(Equal(resourceDescription)) 56 57 Ω(Design.Types).Should(HaveKey(typeName)) 58 Ω(Design.Types[typeName]).ShouldNot(BeNil()) 59 Ω(Design.Types[typeName].TypeName).Should(Equal(typeName)) 60 Ω(Design.Types[typeName].Description).Should(Equal(typeDescription)) 61 62 Ω(Design.MediaTypes).Should(HaveKey(mediaTypeIdentifier)) 63 Ω(Design.MediaTypes[mediaTypeIdentifier]).ShouldNot(BeNil()) 64 Ω(Design.MediaTypes[mediaTypeIdentifier].Identifier).Should(Equal(mediaTypeIdentifier)) 65 Ω(Design.MediaTypes[mediaTypeIdentifier].Description).Should(Equal(mediaTypeDescription)) 66 }) 67 }) 68 }) 69 }