本文整理汇总了Golang中github.com/cloudwan/gohan/db/transaction.Transaction.Close方法的典型用法代码示例。如果您正苦于以下问题:Golang Transaction.Close方法的具体用法?Golang Transaction.Close怎么用?Golang Transaction.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudwan/gohan/db/transaction.Transaction
的用法示例。
在下文中一共展示了Transaction.Close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
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()
示例2:
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 = "[email protected]/gohan_test"
dbType = "mysql"
} else {
conn = "./test.db"
dbType = "sqlite3"
}
})
Context("When the database is empty", func() {
It("Returns an empty list", func() {
示例3: DBClose
//DBClose closes a transaction.
func DBClose(tx transaction.Transaction) error {
return tx.Close()
}