diff --git a/bench_test.go b/bench_test.go index 0ee937ed..75da9016 100644 --- a/bench_test.go +++ b/bench_test.go @@ -63,7 +63,7 @@ func restoreBinaryEncoders(encoders map[pgx.Oid]func(*pgx.MessageReader, int32) } func BenchmarkSelectRowSimpleNarrow(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createNarrowTestData(b, conn) // Get random ids outside of timing @@ -79,7 +79,7 @@ func BenchmarkSelectRowSimpleNarrow(b *testing.B) { } func BenchmarkSelectRowPreparedNarrow(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createNarrowTestData(b, conn) // Get random ids outside of timing @@ -95,7 +95,7 @@ func BenchmarkSelectRowPreparedNarrow(b *testing.B) { } func BenchmarkSelectRowsSimpleNarrow(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createNarrowTestData(b, conn) // Get random ids outside of timing @@ -111,7 +111,7 @@ func BenchmarkSelectRowsSimpleNarrow(b *testing.B) { } func BenchmarkSelectRowsPreparedNarrow(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createNarrowTestData(b, conn) // Get random ids outside of timing @@ -198,7 +198,7 @@ func createJoinsTestData(b *testing.B, conn *pgx.Connection) { } func BenchmarkSelectRowsSimpleJoins(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createJoinsTestData(b, conn) sql := ` @@ -218,7 +218,7 @@ func BenchmarkSelectRowsSimpleJoins(b *testing.B) { } func BenchmarkSelectRowsPreparedJoins(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createJoinsTestData(b, conn) b.ResetTimer() @@ -253,7 +253,7 @@ func createInt2TextVsBinaryTestData(b *testing.B, conn *pgx.Connection) { } func BenchmarkInt2Text(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createInt2TextVsBinaryTestData(b, conn) encoders := removeBinaryEncoders() @@ -269,7 +269,7 @@ func BenchmarkInt2Text(b *testing.B) { } func BenchmarkInt2Binary(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createInt2TextVsBinaryTestData(b, conn) mustPrepare(b, conn, "selectInt16", "select * from t") defer func() { conn.Deallocate("selectInt16") }() @@ -306,7 +306,7 @@ func createInt4TextVsBinaryTestData(b *testing.B, conn *pgx.Connection) { } func BenchmarkInt4Text(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createInt4TextVsBinaryTestData(b, conn) encoders := removeBinaryEncoders() @@ -322,7 +322,7 @@ func BenchmarkInt4Text(b *testing.B) { } func BenchmarkInt4Binary(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createInt4TextVsBinaryTestData(b, conn) mustPrepare(b, conn, "selectInt32", "select * from t") defer func() { conn.Deallocate("selectInt32") }() @@ -359,7 +359,7 @@ func createInt8TextVsBinaryTestData(b *testing.B, conn *pgx.Connection) { } func BenchmarkInt8Text(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createInt8TextVsBinaryTestData(b, conn) encoders := removeBinaryEncoders() @@ -375,7 +375,7 @@ func BenchmarkInt8Text(b *testing.B) { } func BenchmarkInt8Binary(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createInt8TextVsBinaryTestData(b, conn) mustPrepare(b, conn, "selectInt64", "select * from t") defer func() { conn.Deallocate("selectInt64") }() @@ -412,7 +412,7 @@ func createFloat4TextVsBinaryTestData(b *testing.B, conn *pgx.Connection) { } func BenchmarkFloat4Text(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createFloat4TextVsBinaryTestData(b, conn) encoders := removeBinaryEncoders() @@ -428,7 +428,7 @@ func BenchmarkFloat4Text(b *testing.B) { } func BenchmarkFloat4Binary(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createFloat4TextVsBinaryTestData(b, conn) mustPrepare(b, conn, "selectFloat32", "select * from t") defer func() { conn.Deallocate("selectFloat32") }() @@ -465,7 +465,7 @@ func createFloat8TextVsBinaryTestData(b *testing.B, conn *pgx.Connection) { } func BenchmarkFloat8Text(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createFloat8TextVsBinaryTestData(b, conn) encoders := removeBinaryEncoders() @@ -481,7 +481,7 @@ func BenchmarkFloat8Text(b *testing.B) { } func BenchmarkFloat8Binary(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createFloat8TextVsBinaryTestData(b, conn) mustPrepare(b, conn, "selectFloat32", "select * from t") defer func() { conn.Deallocate("selectFloat32") }() @@ -518,7 +518,7 @@ func createBoolTextVsBinaryTestData(b *testing.B, conn *pgx.Connection) { } func BenchmarkBoolText(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createBoolTextVsBinaryTestData(b, conn) encoders := removeBinaryEncoders() @@ -534,7 +534,7 @@ func BenchmarkBoolText(b *testing.B) { } func BenchmarkBoolBinary(b *testing.B) { - conn := GetSharedConnection() + conn := getSharedConnection() createBoolTextVsBinaryTestData(b, conn) mustPrepare(b, conn, "selectBool", "select * from t") defer func() { conn.Deallocate("selectBool") }() diff --git a/connection_test.go b/connection_test.go index 2bdbc27b..46c37613 100644 --- a/connection_test.go +++ b/connection_test.go @@ -121,7 +121,7 @@ func TestConnectWithMD5Password(t *testing.T) { } func TestExecute(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() if results := mustExecute(t, conn, "create temporary table foo(id integer primary key);"); results != "CREATE TABLE" { t.Error("Unexpected results from Execute") @@ -164,7 +164,7 @@ func TestExecuteFailure(t *testing.T) { } func TestSelectFunc(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() var sum, rowCount int32 onDataRow := func(r *pgx.DataRowReader) error { @@ -203,7 +203,7 @@ func TestSelectFuncFailure(t *testing.T) { } func TestSelectRows(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() rows := mustSelectRows(t, conn, "select $1 as name, null as position", "Jack") @@ -225,7 +225,7 @@ func TestSelectRows(t *testing.T) { } func TestSelectRow(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() row := mustSelectRow(t, conn, "select $1 as name, null as position", "Jack") if row["name"] != "Jack" { @@ -252,7 +252,7 @@ func TestSelectRow(t *testing.T) { } func TestConnectionSelectValue(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() test := func(sql string, expected interface{}, arguments ...interface{}) { v, err := conn.SelectValue(sql, arguments...) @@ -292,7 +292,7 @@ func TestConnectionSelectValue(t *testing.T) { } func TestSelectValues(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() test := func(sql string, expected []interface{}, arguments ...interface{}) { values, err := conn.SelectValues(sql, arguments...) diff --git a/data_row_reader_test.go b/data_row_reader_test.go index 052f5d78..25b0ce38 100644 --- a/data_row_reader_test.go +++ b/data_row_reader_test.go @@ -6,7 +6,7 @@ import ( ) func TestDataRowReaderReadValue(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() test := func(sql string, expected interface{}) { var v interface{} diff --git a/helper_test.go b/helper_test.go index c671db3c..fed4dc39 100644 --- a/helper_test.go +++ b/helper_test.go @@ -8,18 +8,18 @@ type test interface { Fatalf(format string, args ...interface{}) } -var SharedConnection *pgx.Connection +var sharedConnection *pgx.Connection -func GetSharedConnection() (c *pgx.Connection) { - if SharedConnection == nil { +func getSharedConnection() (c *pgx.Connection) { + if sharedConnection == nil { var err error - SharedConnection, err = pgx.Connect(*defaultConnectionParameters) + sharedConnection, err = pgx.Connect(*defaultConnectionParameters) if err != nil { panic("Unable to establish connection") } } - return SharedConnection + return sharedConnection } func mustPrepare(t test, conn *pgx.Connection, name, sql string) { diff --git a/sanitize_test.go b/sanitize_test.go index 79a9fbe1..36123091 100644 --- a/sanitize_test.go +++ b/sanitize_test.go @@ -5,7 +5,7 @@ import ( ) func TestQuoteString(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() if conn.QuoteString("test") != "'test'" { t.Error("Failed to quote string") @@ -17,7 +17,7 @@ func TestQuoteString(t *testing.T) { } func TestSanitizeSql(t *testing.T) { - conn := GetSharedConnection() + conn := getSharedConnection() if conn.SanitizeSql("select $1", "Jack's") != "select 'Jack''s'" { t.Error("Failed to sanitize string")