|
@@ -44,6 +44,23 @@ var _ = Describe("gosql", func() {
|
|
|
// Expect(id).To(Equal(2))
|
|
|
// Expect(name).To(Equal("Bob"))
|
|
|
|
|
|
+ // Expect(db.Close()).To(Succeed())
|
|
|
+ // })
|
|
|
+
|
|
|
+ // It("open connection, migrate and select by ID", func() {
|
|
|
+ // db, err := gosql.Open("mysql://root:root@127.0.0.1:3306/gosql", migrationsDir, false, false)
|
|
|
+ // Expect(err).To(Succeed())
|
|
|
+
|
|
|
+ // var rowUser struct {
|
|
|
+ // ID int64 `field:"id" table:"users"`
|
|
|
+ // Name string `field:"name"`
|
|
|
+ // }
|
|
|
+
|
|
|
+ // err = db.QueryRowByID(ctx, 1, &rowUser)
|
|
|
+ // Expect(err).To(Succeed())
|
|
|
+ // Expect(rowUser.ID).To(Equal(int64(1)))
|
|
|
+ // Expect(rowUser.Name).To(Equal("Alice"))
|
|
|
+
|
|
|
// Expect(db.Close()).To(Succeed())
|
|
|
// })
|
|
|
// })
|
|
@@ -64,6 +81,23 @@ var _ = Describe("gosql", func() {
|
|
|
// Expect(id).To(Equal(2))
|
|
|
// Expect(name).To(Equal("Bob"))
|
|
|
|
|
|
+ // Expect(db.Close()).To(Succeed())
|
|
|
+ // })
|
|
|
+
|
|
|
+ // It("open connection, migrate and select by ID", func() {
|
|
|
+ // db, err := gosql.Open("postgres://root:root@127.0.0.1:5432/gosql?sslmode=disable", migrationsDir, false, false)
|
|
|
+ // Expect(err).To(Succeed())
|
|
|
+
|
|
|
+ // var rowUser struct {
|
|
|
+ // ID int64 `field:"id" table:"users"`
|
|
|
+ // Name string `field:"name"`
|
|
|
+ // }
|
|
|
+
|
|
|
+ // err = db.QueryRowByID(ctx, 1, &rowUser)
|
|
|
+ // Expect(err).To(Succeed())
|
|
|
+ // Expect(rowUser.ID).To(Equal(int64(1)))
|
|
|
+ // Expect(rowUser.Name).To(Equal("Alice"))
|
|
|
+
|
|
|
// Expect(db.Close()).To(Succeed())
|
|
|
// })
|
|
|
// })
|
|
@@ -89,6 +123,27 @@ var _ = Describe("gosql", func() {
|
|
|
|
|
|
Expect(db.Close()).To(Succeed())
|
|
|
})
|
|
|
+
|
|
|
+ It("open connection, migrate and select by ID", func() {
|
|
|
+ f, err := ioutil.TempFile("", "go-sqlite-test-")
|
|
|
+ Expect(err).To(Succeed())
|
|
|
+ f.Close()
|
|
|
+
|
|
|
+ db, err := gosql.Open("sqlite://"+f.Name(), migrationsDir, false, false)
|
|
|
+ Expect(err).To(Succeed())
|
|
|
+
|
|
|
+ var rowUser struct {
|
|
|
+ ID int64 `field:"id" table:"users"`
|
|
|
+ Name string `field:"name"`
|
|
|
+ }
|
|
|
+
|
|
|
+ err = db.QueryRowByID(ctx, 1, &rowUser)
|
|
|
+ Expect(err).To(Succeed())
|
|
|
+ Expect(rowUser.ID).To(Equal(int64(1)))
|
|
|
+ Expect(rowUser.Name).To(Equal("Alice"))
|
|
|
+
|
|
|
+ Expect(db.Close()).To(Succeed())
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
It("open connection and skip migration", func() {
|