本文整理汇总了Golang中github.com/goadesign/goa/dslengine.Run函数的典型用法代码示例。如果您正苦于以下问题:Golang Run函数的具体用法?Golang Run怎么用?Golang Run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Run函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ParseDSL
// ParseDSL will run the DSL engine and analyze any imported `design`
// package, creating your `design.APIDefinition` along the way.
func ParseDSL() {
// Catch any init-time errors
dslengine.FailOnError(dslengine.Errors)
// Catch any runtime errors, when analyzing the DSL
dslengine.FailOnError(dslengine.Run())
}
开发者ID:konstantin-dzreev,项目名称:goa,代码行数:9,代码来源:run.go
示例2: init
func init() {
dslengine.Run()
var _ = Describe("DSL execution", func() {
Context("with global DSL definitions", func() {
It("runs the DSL", func() {
Ω(dslengine.Errors).Should(BeEmpty())
Ω(Design).ShouldNot(BeNil())
Ω(Design.Name).Should(Equal(apiName))
Ω(Design.Description).Should(Equal(apiDescription))
Ω(Design.Resources).Should(HaveKey(resourceName))
Ω(Design.Resources[resourceName]).ShouldNot(BeNil())
Ω(Design.Resources[resourceName].Name).Should(Equal(resourceName))
Ω(Design.Resources[resourceName].Description).Should(Equal(resourceDescription))
Ω(Design.Types).Should(HaveKey(typeName))
Ω(Design.Types[typeName]).ShouldNot(BeNil())
Ω(Design.Types[typeName].TypeName).Should(Equal(typeName))
Ω(Design.Types[typeName].Description).Should(Equal(typeDescription))
Ω(Design.MediaTypes).Should(HaveKey(mediaTypeIdentifier))
Ω(Design.MediaTypes[mediaTypeIdentifier]).ShouldNot(BeNil())
Ω(Design.MediaTypes[mediaTypeIdentifier].Identifier).Should(Equal(mediaTypeIdentifier))
Ω(Design.MediaTypes[mediaTypeIdentifier].Description).Should(Equal(mediaTypeDescription))
})
})
})
}
开发者ID:ajoulie,项目名称:goa,代码行数:30,代码来源:runner_test.go
示例3:
InitDesign()
API("foo", func() {})
var type1, type2 *UserTypeDefinition
type1 = Type(type1Name, func() {
Attribute(att1Name, type2)
})
type2 = Type(type2Name, func() {
Attribute(att2Name, type1)
})
})
JustBeforeEach(func() {
dslengine.Run()
})
It("still produces the correct metadata", func() {
Ω(dslengine.Errors).Should(BeEmpty())
Ω(Design.Types).Should(HaveLen(2))
t1 := Design.Types[type1Name]
t2 := Design.Types[type2Name]
Ω(t1).ShouldNot(BeNil())
Ω(t2).ShouldNot(BeNil())
Ω(t1.Type).Should(BeAssignableToTypeOf(Object{}))
Ω(t2.Type).Should(BeAssignableToTypeOf(Object{}))
o1 := t1.Type.(Object)
o2 := t2.Type.(Object)
Ω(o1).Should(HaveKey(att1Name))
Ω(o2).Should(HaveKey(att2Name))
开发者ID:DavyC,项目名称:goa,代码行数:31,代码来源:runner_test.go
示例4:
})
})
})
var _ = Describe("GoTypeTransform", func() {
var source, target *UserTypeDefinition
var targetPkg, funcName string
var transform string
BeforeEach(func() {
dslengine.Reset()
})
JustBeforeEach(func() {
err := dslengine.Run()
Ω(err).ShouldNot(HaveOccurred())
transform, _ = codegen.GoTypeTransform(source, target, targetPkg, funcName)
})
Context("transforming simple objects", func() {
const attName = "att"
BeforeEach(func() {
source = Type("Source", func() {
Attribute(attName)
})
target = Type("Target", func() {
Attribute(attName)
})
funcName = "Transform"
})
开发者ID:jim-slattery-rs,项目名称:goa,代码行数:31,代码来源:types_test.go
示例5:
var _ = Describe("MediaType", func() {
var name string
var dslFunc func()
var mt *MediaTypeDefinition
BeforeEach(func() {
InitDesign()
dslengine.Errors = nil
name = ""
dslFunc = nil
})
JustBeforeEach(func() {
mt = MediaType(name, dslFunc)
dslengine.Run()
Ω(dslengine.Errors).ShouldNot(HaveOccurred())
})
Context("with no dsl and no identifier", func() {
It("produces an error", func() {
Ω(mt).ShouldNot(BeNil())
Ω(mt.Validate()).Should(HaveOccurred())
})
})
Context("with no dsl", func() {
BeforeEach(func() {
name = "application/foo"
})
开发者ID:intfrr,项目名称:goa,代码行数:30,代码来源:media_type_test.go
示例6:
TypeName("Mt2")
Attributes(func() {
Attribute("att2", mt)
})
Links(func() {
Link("att2", "default")
})
View("default", func() {
Attribute("att2")
Attribute("links")
})
View("tiny", func() {
Attribute("links")
})
})
err := dslengine.Run()
Ω(err).ShouldNot(HaveOccurred())
Ω(dslengine.Errors).ShouldNot(HaveOccurred())
})
Context("using the default view", func() {
BeforeEach(func() {
view = "default"
})
It("returns the projected media type with links", func() {
Ω(prErr).ShouldNot(HaveOccurred())
Ω(projected).ShouldNot(BeNil())
Ω(projected.Type).Should(BeAssignableToTypeOf(Object{}))
Ω(projected.Type.ToObject()).Should(HaveKey("att"))
l := projected.Type.ToObject()["links"]
开发者ID:smessier,项目名称:goa,代码行数:31,代码来源:types_test.go
示例7:
JustBeforeEach(func() {
s = genschema.TypeSchema(design.Design, typ)
})
Context("with a media type", func() {
BeforeEach(func() {
MediaType("application/foo.bar", func() {
Attributes(func() {
Attribute("bar")
})
View("default", func() {
Attribute("bar")
})
})
Ω(dslengine.Run()).ShouldNot(HaveOccurred())
typ = design.Design.MediaTypes["application/foo.bar"]
})
It("returns a proper JSON schema type", func() {
Ω(s).ShouldNot(BeNil())
Ω(s.Ref).Should(Equal("#/definitions/FooBar"))
})
})
Context("with a media type with self-referencing attributes", func() {
BeforeEach(func() {
MediaType("application/vnd.menu+json", func() {
Attributes(func() {
Attribute("name", design.String, "The name of an application")
Attribute("children", CollectionOf("application/vnd.menu+json"), func() {
开发者ID:konstantin-dzreev,项目名称:goa,代码行数:31,代码来源:json_schema_test.go
注:本文中的github.com/goadesign/goa/dslengine.Run函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论