Ejemplo n.º 1
0
		ft = gorma.String
		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"
		})
Ejemplo n.º 2
0
					gdsl.BuiltFrom(HasManyPayload)
					gdsl.HasMany("Children", "Child")
				})

			})
		})

		Run()

	})

	Context("with no DSL", func() {
		BeforeEach(func() {
			name = "Users"
			dsl = func() {
				gdsl.Field("ID", gorma.PKInteger)
				gdsl.Field("CreatedAt", gorma.Timestamp)
				gdsl.Field("UpdatedAt", gorma.Timestamp)
				gdsl.Field("DeletedAt", gorma.NullableTimestamp)
			}
		})

		It("generates auto fields", func() {
			Ω(Design.Validate()).ShouldNot(HaveOccurred())
			sg := gorma.GormaDesign
			rs := sg.RelationalStores[storename]
			Ω(rs.RelationalModels[name].Name).Should(Equal(name))
			_, ok := rs.RelationalModels[name].RelationalFields["ID"]
			Ω(ok).Should(Equal(true))
			_, ok = rs.RelationalModels[name].RelationalFields["UpdatedAt"]
			Ω(ok).Should(Equal(true))