From 70d420ba858809bf532fca39ec995e3f33e2874c Mon Sep 17 00:00:00 2001 From: snoop Date: Tue, 8 Nov 2016 17:04:20 +0900 Subject: [PATCH] added test --- test/insert_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/insert_test.go diff --git a/test/insert_test.go b/test/insert_test.go new file mode 100644 index 0000000..138f883 --- /dev/null +++ b/test/insert_test.go @@ -0,0 +1,35 @@ +package test + +import ( + "loafle.com/commons/orm/orm" + _ "loafle.com/commons/orm/orm/dialects/h2" + "log" + "testing" +) + +type Animal struct { + ID int64 `sql:"AUTO_INCREMENT" gorm:"primary_key"` + Types string + Name string +} + +func TestH2Insert(t *testing.T) { + + db, err := orm.Open("h2", "host=192.168.1.215 port=5435 user=sa dbname=ttt sslmode=disable password=qwe123") + + if err != nil { + log.Println(err) + return + } + + defer db.Close() + + db.LogMode(true) + + db.CreateTable(&Animal{}) + + ani := Animal{Types: "CAT", Name: "CATIA"} + + db.Create(&ani) + +}