dex/vendor/github.com/lib/pq/conn_xact_test.go

62 lines
996 B
Go
Raw Normal View History

2016-04-09 00:26:29 +05:30
// +build go1.1
package pq
import (
"testing"
)
func TestXactMultiStmt(t *testing.T) {
// minified test case based on bug reports from
// pico303@gmail.com and rangelspam@gmail.com
t.Skip("Skipping failing test")
db := openTestConn(t)
defer db.Close()
tx, err := db.Begin()
if err != nil {
t.Fatal(err)
}
defer tx.Commit()
rows, err := tx.Query("select 1")
if err != nil {
t.Fatal(err)
}
if rows.Next() {
var val int32
if err = rows.Scan(&val); err != nil {
t.Fatal(err)
}
} else {
t.Fatal("Expected at least one row in first query in xact")
}
rows2, err := tx.Query("select 2")
if err != nil {
t.Fatal(err)
}
if rows2.Next() {
var val2 int32
if err := rows2.Scan(&val2); err != nil {
t.Fatal(err)
}
} else {
t.Fatal("Expected at least one row in second query in xact")
}
if err = rows.Err(); err != nil {
t.Fatal(err)
}
if err = rows2.Err(); err != nil {
t.Fatal(err)
}
if err = tx.Commit(); err != nil {
t.Fatal(err)
}
}