gorma.GormaDesign = nil InitDesign() RandomPayload = Type("UserPayload", func() { Attribute("first_name", String) Attribute("last_name", String) }) }) JustBeforeEach(func() { gdsl.StorageGroup(sgname, func() { gdsl.Store(storename, gorma.MySQL, func() { gdsl.Model(modelname, func() { gdsl.BuiltFrom(RandomPayload) gdsl.Field(name, ft, dsl) gdsl.Field("id", gorma.PKInteger, dsl) // use lowercase "id" to test sanitizer gdsl.Field("CreatedAt", gorma.Timestamp) gdsl.Field("UpdatedAt", gorma.Timestamp) gdsl.Field("DeletedAt", gorma.NullableTimestamp) }) }) }) Run() }) Context("with no DSL", func() { BeforeEach(func() { name = "FirstName" }) It("produces a valid Relational Field definition", func() {
BeforeEach(func() { Design = nil Errors = nil sgname = "production" dsl = nil name = "" gorma.GormaDesign = nil InitDesign() }) JustBeforeEach(func() { gdsl.StorageGroup(sgname, func() { gdsl.Store(name, gorma.MySQL, dsl) }) Run() }) Context("with no DSL", func() { BeforeEach(func() { name = "mysql" }) It("produces a valid Relational Store definition", func() { Ω(Design.Validate()).ShouldNot(HaveOccurred()) sg := gorma.GormaDesign Ω(sg.RelationalStores[name].Name).Should(Equal(name))
. "github.com/onsi/gomega" ) var _ = Describe("StorageGroup", func() { var name string var dsl func() BeforeEach(func() { Reset() name = "mysql" dsl = nil }) JustBeforeEach(func() { gdsl.StorageGroup(name, dsl) Run() }) Context("with no DSL", func() { BeforeEach(func() { name = "mysql" }) It("produces a valid Storage Group definition", func() { Ω(Design.Validate()).ShouldNot(HaveOccurred()) Ω(gorma.GormaDesign.Name).Should(Equal(name)) }) })
Attribute("first_name", String) Attribute("last_name", String) }) }) JustBeforeEach(func() { gdsl.StorageGroup(sgname, func() { gdsl.Store(storename, gorma.MySQL, func() { gdsl.Model(name, dsl) gdsl.Model("Child", func() { gdsl.BuiltFrom(ChildPayload) gdsl.BelongsTo(name) }) gdsl.Model("One", func() { gdsl.BuiltFrom(HasOnePayload) gdsl.HasOne("Child") }) gdsl.Model("Many", func() { gdsl.BuiltFrom(HasManyPayload) gdsl.HasMany("Children", "Child") }) }) }) Run() }) Context("with no DSL", func() { BeforeEach(func() {
JustBeforeEach(func() { modeldsl = func() { //gdsl.BuildsFrom(RandomPayload) gdsl.Field(name, ft, dsl) gdsl.Field("id", gorma.Integer, dsl) // use lowercase "id" to test sanitizer gdsl.Field("MiddleName", gorma.String) gdsl.Field("CreatedAt", gorma.Timestamp) gdsl.Field("UpdatedAt", gorma.Timestamp) gdsl.Field("DeletedAt", gorma.NullableTimestamp) } gdsl.StorageGroup(sgname, func() { gdsl.Store(storename, gorma.MySQL, func() { gdsl.Model(modelname, modeldsl) }) }) Run() }) Context("with no DSL", func() { BeforeEach(func() { name = "FirstName" }) It("produces a valid Relational Field definition", func() { Ω(Design.Validate()).ShouldNot(HaveOccurred()) sg := gorma.GormaDesign rs := sg.RelationalStores[storename]