-- | Tests multi-command simple query.
testSimpleQuery :: IO ()
testSimpleQuery = withConnectionCommonAll $ \c -> do
    let rawConn = connRawConnection c
        statement = StatementSQL $
               "DROP TABLE IF EXISTS a;"
            <> "CREATE TABLE a(v int);"
            <> "INSERT INTO a VALUES (1), (2), (3);"
            <> "SELECT * FROM a;"
            <> "DROP TABLE a;"
    sendMessage rawConn $ SimpleQuery statement
    msgs <- collectUntilReadyForQuery c
    assertNoErrorResponse msgs
    assertContains msgs isCommandComplete "Command complete"
  where
    isCommandComplete (CommandComplete _) = True
    isCommandComplete _                   = False

-- Tests all messages that are permitted in extended query protocol.
testSimpleQuery :: IO ()
testSimpleQuery = withConnectionCommonAll $ \c -> do
    let rawConn = connRawConnection c
        statement = StatementSQL $
               "DROP TABLE IF EXISTS a;"
            <> "CREATE TABLE a(v int);"
            <> "INSERT INTO a VALUES (1), (2), (3);"
            <> "SELECT * FROM a;"
            <> "DROP TABLE a;"
    sendMessage rawConn $ SimpleQuery statement
    msgs <- collectUntilReadyForQuery c
    assertNoErrorResponse msgs
    assertContains msgs isCommandComplete "Command complete"
  where
    isCommandComplete (CommandComplete _) = True
    isCommandComplete _                   = False

-- Tests all messages that are permitted in extended query protocol.
testSimpleQuery = withConnectionCommonAll $ \c -> do
    let rawConn = connRawConnection c
        statement = StatementSQL $
               "DROP TABLE IF EXISTS a;"
            <> "CREATE TABLE a(v int);"
            <> "INSERT INTO a VALUES (1), (2), (3);"
            <> "SELECT * FROM a;"
            <> "DROP TABLE a;"
    sendMessage rawConn $ SimpleQuery statement
    msgs <- collectUntilReadyForQuery c
    assertNoErrorResponse msgs
    assertContains msgs isCommandComplete "Command complete"
  where
    isCommandComplete (CommandComplete _) = True
    isCommandComplete _                   = False

-- Tests all messages that are permitted in extended query protocol.