예제 #1
0
		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() {
예제 #2
0
	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))
예제 #3
0
	. "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))
		})
	})
예제 #4
0
			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() {
예제 #5
0
	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]