Browse Source

Enable MySQL & PG tests

Volodymyr Tkach 2 years ago
parent
commit
0dcdc775fe
2 changed files with 58 additions and 58 deletions
  1. 19 19
      gosql/common/common_test.go
  2. 39 39
      gosql/gosql_test.go

+ 19 - 19
gosql/common/common_test.go

@@ -104,25 +104,25 @@ var _ = Describe("common", func() {
 		})
 		})
 
 
 		Context("Success", func() {
 		Context("Success", func() {
-			// // Note: you need to up MySQL server for this test case
-			// It("for MySQL", func() {
-			// 	databaseURL, err := url.Parse("mysql://root:root@127.0.0.1:3306/gosql")
-			// 	Expect(err).To(Succeed())
-
-			// 	db, err := common.OpenDB(databaseURL, migrationsDir)
-			// 	Expect(err).To(Succeed())
-			// 	Expect(db.Close()).To(Succeed())
-			// })
-
-			// // Note: you need to up PostgreSQL server for this test case
-			// It("for PostgreSQL", func() {
-			// 	databaseURL, err := url.Parse("postgres://root:root@127.0.0.1:5432/gosql?sslmode=disable")
-			// 	Expect(err).To(Succeed())
-
-			// 	db, err := common.OpenDB(databaseURL, migrationsDir)
-			// 	Expect(err).To(Succeed())
-			// 	Expect(db.Close()).To(Succeed())
-			// })
+			// Note: you need to up MySQL server for this test case
+			It("for MySQL", func() {
+				databaseURL, err := url.Parse("mysql://root:root@127.0.0.1:3306/gosql")
+				Expect(err).To(Succeed())
+
+				db, err := common.OpenDB(databaseURL, migrationsDir)
+				Expect(err).To(Succeed())
+				Expect(db.Close()).To(Succeed())
+			})
+
+			// Note: you need to up PostgreSQL server for this test case
+			It("for PostgreSQL", func() {
+				databaseURL, err := url.Parse("postgres://root:root@127.0.0.1:5432/gosql?sslmode=disable")
+				Expect(err).To(Succeed())
+
+				db, err := common.OpenDB(databaseURL, migrationsDir)
+				Expect(err).To(Succeed())
+				Expect(db.Close()).To(Succeed())
+			})
 
 
 			It("for SQLite", func() {
 			It("for SQLite", func() {
 				f, err := ioutil.TempFile("", "go-sqlite3-test-")
 				f, err := ioutil.TempFile("", "go-sqlite3-test-")

+ 39 - 39
gosql/gosql_test.go

@@ -28,45 +28,45 @@ var _ = Describe("gosql", func() {
 			Expect(err).To(Succeed())
 			Expect(err).To(Succeed())
 		})
 		})
 
 
-		// // Note: you need to up MySQL server for this test case
-		// Context("for MySQL", func() {
-		// 	It("open connection, migrate and select data", func() {
-		// 		db, err := gosql.Open("mysql://root:root@127.0.0.1:3306/gosql", migrationsDir, false)
-		// 		Expect(err).To(Succeed())
-
-		// 		err = db.QueryRow(ctx, sql, 1).Scan(&id, &name)
-		// 		Expect(err).To(Succeed())
-		// 		Expect(id).To(Equal(1))
-		// 		Expect(name).To(Equal("alice"))
-
-		// 		err = db.QueryRow(ctx, sql, 2).Scan(&id, &name)
-		// 		Expect(err).To(Succeed())
-		// 		Expect(id).To(Equal(2))
-		// 		Expect(name).To(Equal("bob"))
-
-		// 		Expect(db.Close()).To(Succeed())
-		// 	})
-		// })
-
-		// // Note: you need to up PostgreSQL server for this test case
-		// Context("for PostgreSQL", func() {
-		// 	It("open connection, migrate and select data", func() {
-		// 		db, err := gosql.Open("postgres://root:root@127.0.0.1:5432/gosql?sslmode=disable", migrationsDir, false)
-		// 		Expect(err).To(Succeed())
-
-		// 		err = db.QueryRow(ctx, sql, 1).Scan(&id, &name)
-		// 		Expect(err).To(Succeed())
-		// 		Expect(id).To(Equal(1))
-		// 		Expect(name).To(Equal("alice"))
-
-		// 		err = db.QueryRow(ctx, sql, 2).Scan(&id, &name)
-		// 		Expect(err).To(Succeed())
-		// 		Expect(id).To(Equal(2))
-		// 		Expect(name).To(Equal("bob"))
-
-		// 		Expect(db.Close()).To(Succeed())
-		// 	})
-		// })
+		// Note: you need to up MySQL server for this test case
+		Context("for MySQL", func() {
+			It("open connection, migrate and select data", func() {
+				db, err := gosql.Open("mysql://root:root@127.0.0.1:3306/gosql", migrationsDir, false)
+				Expect(err).To(Succeed())
+
+				err = db.QueryRow(ctx, sql, 1).Scan(&id, &name)
+				Expect(err).To(Succeed())
+				Expect(id).To(Equal(1))
+				Expect(name).To(Equal("alice"))
+
+				err = db.QueryRow(ctx, sql, 2).Scan(&id, &name)
+				Expect(err).To(Succeed())
+				Expect(id).To(Equal(2))
+				Expect(name).To(Equal("bob"))
+
+				Expect(db.Close()).To(Succeed())
+			})
+		})
+
+		// Note: you need to up PostgreSQL server for this test case
+		Context("for PostgreSQL", func() {
+			It("open connection, migrate and select data", func() {
+				db, err := gosql.Open("postgres://root:root@127.0.0.1:5432/gosql?sslmode=disable", migrationsDir, false)
+				Expect(err).To(Succeed())
+
+				err = db.QueryRow(ctx, sql, 1).Scan(&id, &name)
+				Expect(err).To(Succeed())
+				Expect(id).To(Equal(1))
+				Expect(name).To(Equal("alice"))
+
+				err = db.QueryRow(ctx, sql, 2).Scan(&id, &name)
+				Expect(err).To(Succeed())
+				Expect(id).To(Equal(2))
+				Expect(name).To(Equal("bob"))
+
+				Expect(db.Close()).To(Succeed())
+			})
+		})
 
 
 		Context("for SQLite", func() {
 		Context("for SQLite", func() {
 			It("open connection, migrate and select data", func() {
 			It("open connection, migrate and select data", func() {