mirror of https://github.com/jackc/pgx.git
Fix go vet identified format strings
parent
5679574bca
commit
9d7cf39563
|
@ -479,7 +479,7 @@ func TestConnPoolQuery(t *testing.T) {
|
|||
}
|
||||
|
||||
if rows.Err() != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
if rowCount != 10 {
|
||||
|
@ -528,7 +528,7 @@ func TestConnPoolQueryConcurrentLoad(t *testing.T) {
|
|||
}
|
||||
|
||||
if rows.Err() != nil {
|
||||
t.Fatalf("conn.Query failed: ", rows.Err())
|
||||
t.Fatalf("conn.Query failed: %v", rows.Err())
|
||||
}
|
||||
|
||||
if rowCount != 1000 {
|
||||
|
|
14
conn_test.go
14
conn_test.go
|
@ -543,7 +543,7 @@ func TestParseEnvLibpq(t *testing.T) {
|
|||
for k, v := range savedEnv {
|
||||
err := os.Setenv(k, v)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to restore environment:", err)
|
||||
t.Fatalf("Unable to restore environment: %v", err)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
@ -685,14 +685,14 @@ func TestParseEnvLibpq(t *testing.T) {
|
|||
for _, n := range pgEnvvars {
|
||||
err := os.Unsetenv(n)
|
||||
if err != nil {
|
||||
t.Fatalf("%s: Unable to clear environment:", tt.name, err)
|
||||
t.Fatalf("%s: Unable to clear environment: %v", tt.name, err)
|
||||
}
|
||||
}
|
||||
|
||||
for k, v := range tt.envvars {
|
||||
err := os.Setenv(k, v)
|
||||
if err != nil {
|
||||
t.Fatalf("%s: Unable to set environment:", tt.name, err)
|
||||
t.Fatalf("%s: Unable to set environment: %v", tt.name, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ func TestListenNotifyWhileBusyIsSafe(t *testing.T) {
|
|||
|
||||
rows, err := conn.Query("select generate_series(1,$1)", 100)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
|
@ -1114,7 +1114,7 @@ func TestListenNotifyWhileBusyIsSafe(t *testing.T) {
|
|||
}
|
||||
|
||||
if rows.Err() != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
if sum != 5050 {
|
||||
|
@ -1317,7 +1317,7 @@ func TestCatchSimultaneousConnectionQueries(t *testing.T) {
|
|||
|
||||
rows1, err := conn.Query("select generate_series(1,$1)", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
defer rows1.Close()
|
||||
|
||||
|
@ -1335,7 +1335,7 @@ func TestCatchSimultaneousConnectionQueryAndExec(t *testing.T) {
|
|||
|
||||
rows, err := conn.Query("select generate_series(1,$1)", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func ensureConnValid(t *testing.T, conn *pgx.Conn) {
|
|||
|
||||
rows, err := conn.Query("select generate_series(1,$1)", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
|
@ -46,7 +46,7 @@ func ensureConnValid(t *testing.T, conn *pgx.Conn) {
|
|||
}
|
||||
|
||||
if rows.Err() != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
if rowCount != 10 {
|
||||
|
|
|
@ -146,13 +146,13 @@ func ParseHstore(s string) (k []string, v []NullString, err error) {
|
|||
case r == 'N':
|
||||
state = hsNul
|
||||
default:
|
||||
err = fmt.Errorf("Invalid character '%s' after '=>', expecting '\"' or 'NULL'")
|
||||
err = fmt.Errorf("Invalid character '%c' after '=>', expecting '\"' or 'NULL'", r)
|
||||
}
|
||||
default:
|
||||
err = fmt.Errorf("Invalid character after '=', expecting '>'")
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("Invalid character '%s' after value, expecting '='", r)
|
||||
err = fmt.Errorf("Invalid character '%c' after value, expecting '='", r)
|
||||
}
|
||||
case hsVal:
|
||||
switch r {
|
||||
|
@ -201,10 +201,10 @@ func ParseHstore(s string) (k []string, v []NullString, err error) {
|
|||
r, end = p.Consume()
|
||||
state = hsKey
|
||||
default:
|
||||
err = fmt.Errorf("Invalid character '%s' after ', ', expecting \"", r)
|
||||
err = fmt.Errorf("Invalid character '%c' after ', ', expecting \"", r)
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("Invalid character '%s' after value, expecting ','", r)
|
||||
err = fmt.Errorf("Invalid character '%c' after value, expecting ','", r)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ func TestNullHstoreTranscode(t *testing.T) {
|
|||
outValue, ok := result.Hstore[key]
|
||||
if ok {
|
||||
if inValue != outValue {
|
||||
t.Errorf(`%s: Key %s mismatch - expected %s, received %s`, tt.description, key, inValue, outValue)
|
||||
t.Errorf(`%s: Key %s mismatch - expected %v, received %v`, tt.description, key, inValue, outValue)
|
||||
}
|
||||
} else {
|
||||
t.Errorf(`%s: Missing key %s`, tt.description, key)
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestConnQueryScan(t *testing.T) {
|
|||
|
||||
rows, err := conn.Query("select generate_series(1,$1)", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
|
@ -33,7 +33,7 @@ func TestConnQueryScan(t *testing.T) {
|
|||
}
|
||||
|
||||
if rows.Err() != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
if rowCount != 10 {
|
||||
|
@ -54,7 +54,7 @@ func TestConnQueryValues(t *testing.T) {
|
|||
|
||||
rows, err := conn.Query("select 'foo', n, null, n::oid from generate_series(1,$1) n", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
|
@ -80,7 +80,7 @@ func TestConnQueryValues(t *testing.T) {
|
|||
}
|
||||
|
||||
if values[2] != nil {
|
||||
t.Errorf(`Expected values[2] to be %d, but it was %d`, nil, values[2])
|
||||
t.Errorf(`Expected values[2] to be %v, but it was %d`, nil, values[2])
|
||||
}
|
||||
|
||||
if values[3] != pgx.Oid(rowCount) {
|
||||
|
@ -89,7 +89,7 @@ func TestConnQueryValues(t *testing.T) {
|
|||
}
|
||||
|
||||
if rows.Err() != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
if rowCount != 10 {
|
||||
|
@ -107,7 +107,7 @@ func TestConnQueryCloseEarly(t *testing.T) {
|
|||
// Immediately close query without reading any rows
|
||||
rows, err := conn.Query("select generate_series(1,$1)", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
|
@ -116,7 +116,7 @@ func TestConnQueryCloseEarly(t *testing.T) {
|
|||
// Read partial response then close
|
||||
rows, err = conn.Query("select generate_series(1,$1)", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
ok := rows.Next()
|
||||
|
@ -145,7 +145,7 @@ func TestConnQueryReadWrongTypeError(t *testing.T) {
|
|||
// Read a single value incorrectly
|
||||
rows, err := conn.Query("select generate_series(1,$1)", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
rowsRead := 0
|
||||
|
@ -181,7 +181,7 @@ func TestConnQueryReadTooManyValues(t *testing.T) {
|
|||
// Read too many values
|
||||
rows, err := conn.Query("select generate_series(1,$1)", 10)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
rowsRead := 0
|
||||
|
@ -211,7 +211,7 @@ func TestConnQueryScanner(t *testing.T) {
|
|||
|
||||
rows, err := conn.Query("select null::int8, 1::int8")
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
ok := rows.Next()
|
||||
|
@ -222,7 +222,7 @@ func TestConnQueryScanner(t *testing.T) {
|
|||
var n, m pgx.NullInt64
|
||||
err = rows.Scan(&n, &m)
|
||||
if err != nil {
|
||||
t.Fatalf("rows.Scan failed: ", err)
|
||||
t.Fatalf("rows.Scan failed: %v", err)
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
|
@ -282,7 +282,7 @@ func TestConnQueryEncoder(t *testing.T) {
|
|||
|
||||
rows, err := conn.Query("select $1::int8", &n)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
ok := rows.Next()
|
||||
|
@ -293,7 +293,7 @@ func TestConnQueryEncoder(t *testing.T) {
|
|||
var m pgx.NullInt64
|
||||
err = rows.Scan(&m)
|
||||
if err != nil {
|
||||
t.Fatalf("rows.Scan failed: ", err)
|
||||
t.Fatalf("rows.Scan failed: %v", err)
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
|
@ -856,15 +856,15 @@ func TestReadingValueAfterEmptyArray(t *testing.T) {
|
|||
var b int32
|
||||
err := conn.QueryRow("select '{}'::text[], 42::integer").Scan(&a, &b)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.QueryRow failed: ", err)
|
||||
t.Fatalf("conn.QueryRow failed: %v", err)
|
||||
}
|
||||
|
||||
if len(a) != 0 {
|
||||
t.Errorf("Expected 'a' to have length 0, but it was: ", len(a))
|
||||
t.Errorf("Expected 'a' to have length 0, but it was: %d", len(a))
|
||||
}
|
||||
|
||||
if b != 42 {
|
||||
t.Errorf("Expected 'b' to 42, but it was: ", b)
|
||||
t.Errorf("Expected 'b' to 42, but it was: %d", b)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -875,7 +875,7 @@ func TestReadingNullByteArray(t *testing.T) {
|
|||
var a []byte
|
||||
err := conn.QueryRow("select null::text").Scan(&a)
|
||||
if err != nil {
|
||||
t.Fatalf("conn.QueryRow failed: ", err)
|
||||
t.Fatalf("conn.QueryRow failed: %v", err)
|
||||
}
|
||||
|
||||
if a != nil {
|
||||
|
@ -889,7 +889,7 @@ func TestReadingNullByteArrays(t *testing.T) {
|
|||
|
||||
rows, err := conn.Query("select null::text union all select null::text")
|
||||
if err != nil {
|
||||
t.Fatalf("conn.Query failed: ", err)
|
||||
t.Fatalf("conn.Query failed: %v", err)
|
||||
}
|
||||
|
||||
count := 0
|
||||
|
@ -897,14 +897,14 @@ func TestReadingNullByteArrays(t *testing.T) {
|
|||
count++
|
||||
var a []byte
|
||||
if err := rows.Scan(&a); err != nil {
|
||||
t.Fatalf("failed to scan row", err)
|
||||
t.Fatalf("failed to scan row: %v", err)
|
||||
}
|
||||
if a != nil {
|
||||
t.Errorf("Expected 'a' to be nil, but it was: %v", a)
|
||||
}
|
||||
}
|
||||
if count != 2 {
|
||||
t.Errorf("Expected to read 2 rows, read: ", count)
|
||||
t.Errorf("Expected to read 2 rows, read: %d", count)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue