Beispiel #1
0
		Describe("Using chaining builtins", func() {
			BeforeEach(func() {
				schemaID = "network"
			})

			Describe("Using gohan_model_list", func() {
				var (
					tx transaction.Transaction
				)

				BeforeEach(func() {
					resource, err := manager.LoadResource(schemaID, network1)
					Expect(err).NotTo(HaveOccurred())
					tx, err = testDB.Begin()
					Expect(err).NotTo(HaveOccurred())
					defer tx.Close()
					Expect(tx.Create(resource)).To(Succeed())
					Expect(tx.Commit()).To(Succeed())

					action = "read"
				})

				Describe("When invoked correctly", func() {
					Context("With transaction", func() {
						BeforeEach(func() {
							events["test"] = `
								context.networks = gohan_model_list(context, 'network', {});`
						})

						It("Correctly lists elements", func() {
							tx, err := testDB.Begin()
Beispiel #2
0
		JustBeforeEach(func() {
			os.Remove(conn)
			dataStore, err = db.ConnectDB(dbType, conn, db.DefaultMaxOpenConn)
			Expect(err).ToNot(HaveOccurred())

			for _, s := range manager.Schemas() {
				Expect(dataStore.RegisterTable(s, false)).To(Succeed())
			}

			tx, err = dataStore.Begin()
			Expect(err).ToNot(HaveOccurred())
		})

		AfterEach(func() {
			tx.Close()
		})

		Describe("Using sql", func() {
			BeforeEach(func() {
				if os.Getenv("MYSQL_TEST") == "true" {
					conn = "root@/gohan_test"
					dbType = "mysql"
				} else {
					conn = "./test.db"
					dbType = "sqlite3"
				}
			})

			Context("When the database is empty", func() {
				It("Returns an empty list", func() {
Beispiel #3
0
//DBClose closes a transaction.
func DBClose(tx transaction.Transaction) error {
	return tx.Close()
}