2
0

Remove skip test for missing json type

All supported versions of PostgreSQL now have json type.
This commit is contained in:
Jack Christensen
2017-03-03 16:08:00 -06:00
parent 908c439317
commit ed9e8bb168
2 changed files with 3 additions and 25 deletions
+1 -7
View File
@@ -2,6 +2,7 @@ package pgx_test
import ( import (
"fmt" "fmt"
"github.com/jackc/pgx" "github.com/jackc/pgx"
) )
@@ -12,13 +13,6 @@ func Example_JSON() {
return return
} }
if _, ok := conn.PgTypes[pgx.JSONOID]; !ok {
// No JSON type -- must be running against very old PostgreSQL
// Pretend it works
fmt.Println("John", 42)
return
}
type person struct { type person struct {
Name string `json:"name"` Name string `json:"name"`
Age int `json:"age"` Age int `json:"age"`
+2 -18
View File
@@ -3,9 +3,10 @@ package stdlib_test
import ( import (
"bytes" "bytes"
"database/sql" "database/sql"
"testing"
"github.com/jackc/pgx" "github.com/jackc/pgx"
"github.com/jackc/pgx/stdlib" "github.com/jackc/pgx/stdlib"
"testing"
) )
func openDB(t *testing.T) *sql.DB { func openDB(t *testing.T) *sql.DB {
@@ -497,10 +498,6 @@ func TestConnQueryJSONIntoByteSlice(t *testing.T) {
db := openDB(t) db := openDB(t)
defer closeDB(t, db) defer closeDB(t, db)
if !serverHasJSON(t, db) {
t.Skip("Skipping due to server's lack of JSON type")
}
_, err := db.Exec(` _, err := db.Exec(`
create temporary table docs( create temporary table docs(
body json not null body json not null
@@ -537,10 +534,6 @@ func TestConnExecInsertByteSliceIntoJSON(t *testing.T) {
db := openDB(t) db := openDB(t)
defer closeDB(t, db) defer closeDB(t, db)
if !serverHasJSON(t, db) {
t.Skip("Skipping due to server's lack of JSON type")
}
_, err := db.Exec(` _, err := db.Exec(`
create temporary table docs( create temporary table docs(
body json not null body json not null
@@ -575,15 +568,6 @@ func TestConnExecInsertByteSliceIntoJSON(t *testing.T) {
ensureConnValid(t, db) ensureConnValid(t, db)
} }
func serverHasJSON(t *testing.T, db *sql.DB) bool {
var hasJSON bool
err := db.QueryRow(`select exists(select 1 from pg_type where typname='json')`).Scan(&hasJSON)
if err != nil {
t.Fatalf("db.QueryRow unexpectedly failed: %v", err)
}
return hasJSON
}
func TestTransactionLifeCycle(t *testing.T) { func TestTransactionLifeCycle(t *testing.T) {
db := openDB(t) db := openDB(t)
defer closeDB(t, db) defer closeDB(t, db)