Streamline test
This commit is contained in:
+5
-9
@@ -247,15 +247,11 @@ func TestExecContextCancelationCancelsQuery(t *testing.T) {
|
|||||||
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
|
||||||
defer closeConn(t, conn)
|
defer closeConn(t, conn)
|
||||||
|
|
||||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
|
||||||
go func() {
|
_, err := conn.Exec(ctx, "select pg_sleep(1)")
|
||||||
time.Sleep(500 * time.Millisecond)
|
cancel()
|
||||||
cancelFunc()
|
if err != context.DeadlineExceeded {
|
||||||
}()
|
t.Fatalf("Expected context.DeadlineExceeded err, got %v", err)
|
||||||
|
|
||||||
_, err := conn.Exec(ctx, "select pg_sleep(60)")
|
|
||||||
if err != context.Canceled {
|
|
||||||
t.Fatalf("Expected context.Canceled err, got %v", err)
|
|
||||||
}
|
}
|
||||||
if !conn.LastStmtSent() {
|
if !conn.LastStmtSent() {
|
||||||
t.Error("Expected LastStmtSent to return true")
|
t.Error("Expected LastStmtSent to return true")
|
||||||
|
|||||||
Reference in New Issue
Block a user