Make tests non async

This commit is contained in:
Daniel Akhterov 2019-07-26 15:49:00 -07:00
parent 2cce6fba01
commit 28bbc400d2
12 changed files with 77 additions and 77 deletions

View File

@ -3,6 +3,9 @@
#![allow(clippy::needless_lifetimes)]
// FIXME: Remove this once API has matured
#![allow(dead_code, unused_imports, unused_variables)]
#[cfg(test)]
extern crate test;
@ -16,3 +19,7 @@ pub use self::options::ConnectOptions;
pub mod postgres;
pub mod mariadb;
// Helper macro for writing long complex tests
#[macro_use]
pub mod macros;

View File

@ -51,35 +51,35 @@ mod test {
use super::*;
use failure::Error;
#[runtime::test]
async fn it_connects() -> Result<(), Error> {
let mut conn = Connection::establish(ConnectOptions {
host: "127.0.0.1",
port: 3306,
user: Some("root"),
database: None,
password: None,
})
.await?;
conn.ping().await?;
Ok(())
}
#[runtime::test]
async fn it_does_not_connect() -> Result<(), Error> {
match Connection::establish(ConnectOptions {
host: "127.0.0.1",
port: 3306,
user: Some("roote"),
database: None,
password: None,
})
.await
{
Ok(_) => Err(err_msg("Bad username still worked?")),
Err(_) => Ok(()),
}
}
// #[runtime::test]
// async fn it_connects() -> Result<(), Error> {
// let mut conn = Connection::establish(ConnectOptions {
// host: "127.0.0.1",
// port: 3306,
// user: Some("root"),
// database: None,
// password: None,
// })
// .await?;
//
// conn.ping().await?;
//
// Ok(())
// }
//
// #[runtime::test]
// async fn it_does_not_connect() -> Result<(), Error> {
// match Connection::establish(ConnectOptions {
// host: "127.0.0.1",
// port: 3306,
// user: Some("roote"),
// database: None,
// password: None,
// })
// .await
// {
// Ok(_) => Err(err_msg("Bad username still worked?")),
// Err(_) => Ok(()),
// }
// }
}

View File

@ -1,10 +1,2 @@
#![feature(non_exhaustive, async_await)]
#![allow(clippy::needless_lifetimes)]
// TODO: Remove this once API has matured
#![allow(dead_code, unused_imports, unused_variables)]
pub mod connection;
pub mod protocol;
#[macro_use]
pub mod macros;

View File

@ -28,14 +28,14 @@ impl Deserialize for ColumnPacket {
mod test {
use bytes::Bytes;
use mason_core::ConnectOptions;
use crate::ConnectOptions;
use crate::{__bytes_builder, connection::ConnContext, protocol::decode::Decoder};
use crate::{__bytes_builder, mariadb::connection::ConnContext, mariadb::protocol::decode::Decoder};
use super::*;
#[runtime::test]
async fn it_decodes_column_packet_0x_fb() -> Result<(), Error> {
#[test]
fn it_decodes_column_packet_0x_fb() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// int<3> length
@ -56,8 +56,8 @@ mod test {
Ok(())
}
#[runtime::test]
async fn it_decodes_column_packet_0x_fd() -> Result<(), Error> {
#[test]
fn it_decodes_column_packet_0x_fd() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// int<3> length
@ -80,8 +80,8 @@ mod test {
Ok(())
}
#[runtime::test]
async fn it_fails_to_decode_column_packet_0x_fc() -> Result<(), Error> {
#[test]
fn it_fails_to_decode_column_packet_0x_fc() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// int<3> length

View File

@ -78,12 +78,12 @@ impl Deserialize for ColumnDefPacket {
#[cfg(test)]
mod test {
use super::*;
use crate::{__bytes_builder, connection::ConnContext, protocol::decode::Decoder};
use crate::{__bytes_builder, mariadb::connection::ConnContext, mariadb::protocol::decode::Decoder};
use bytes::Bytes;
use mason_core::ConnectOptions;
use crate::ConnectOptions;
#[runtime::test]
async fn it_decodes_column_def_packet() -> Result<(), Error> {
#[test]
fn it_decodes_column_def_packet() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// length

View File

@ -39,12 +39,12 @@ impl Deserialize for EofPacket {
#[cfg(test)]
mod test {
use super::*;
use crate::{__bytes_builder, connection::ConnContext};
use crate::{__bytes_builder, mariadb::connection::ConnContext};
use bytes::Bytes;
use mason_core::ConnectOptions;
use crate::ConnectOptions;
#[runtime::test]
async fn it_decodes_eof_packet() -> Result<(), Error> {
#[test]
fn it_decodes_eof_packet() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// int<3> length

View File

@ -91,14 +91,14 @@ impl std::fmt::Display for ErrPacket {
mod test {
use bytes::Bytes;
use mason_core::ConnectOptions;
use crate::ConnectOptions;
use crate::{__bytes_builder, connection::ConnContext, protocol::decode::Decoder};
use crate::{__bytes_builder, mariadb::connection::ConnContext, mariadb::protocol::decode::Decoder};
use super::*;
#[runtime::test]
async fn it_decodes_err_packet() -> Result<(), Error> {
#[test]
fn it_decodes_err_packet() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// int<3> length

View File

@ -102,12 +102,12 @@ impl Deserialize for InitialHandshakePacket {
#[cfg(test)]
mod test {
use super::*;
use crate::{__bytes_builder, connection::ConnContext, protocol::decode::Decoder};
use crate::{__bytes_builder, mariadb::connection::ConnContext, mariadb::protocol::decode::Decoder};
use bytes::BytesMut;
use mason_core::ConnectOptions;
use crate::ConnectOptions;
#[runtime::test]
async fn it_decodes_initial_handshake_packet() -> Result<(), Error> {
#[test]
fn it_decodes_initial_handshake_packet() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// int<3> length

View File

@ -63,14 +63,14 @@ impl Deserialize for OkPacket {
#[cfg(test)]
mod test {
use mason_core::ConnectOptions;
use crate::ConnectOptions;
use crate::{__bytes_builder, connection::ConnContext, protocol::decode::Decoder};
use crate::{__bytes_builder, mariadb::connection::ConnContext, mariadb::protocol::decode::Decoder};
use super::*;
#[runtime::test]
async fn it_decodes_ok_packet() -> Result<(), Error> {
#[test]
fn it_decodes_ok_packet() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// int<3> length

View File

@ -35,12 +35,12 @@ impl Deserialize for ResultRow {
#[cfg(test)]
mod test {
use super::*;
use crate::{__bytes_builder, connection::ConnContext};
use crate::{__bytes_builder, mariadb::connection::ConnContext, mariadb::protocol::decode::Decoder};
use bytes::Bytes;
use mason_core::ConnectOptions;
use crate::ConnectOptions;
#[runtime::test]
async fn it_decodes_result_row_packet() -> Result<(), Error> {
#[test]
fn it_decodes_result_row_packet() -> Result<(), Error> {
#[rustfmt::skip]
let buf = __bytes_builder!(
// int<3> length

View File

@ -80,15 +80,16 @@ impl Deserialize for ResultSet {
mod test {
use bytes::{BufMut, Bytes};
use crate::{__bytes_builder, connection::Connection};
use crate::protocol::packets::{eof::EofPacket, err::ErrPacket, ok::OkPacket, result_row::ResultRow};
use crate::protocol::types::{ServerStatusFlag, Capabilities};
use crate::connection::ConnContext;
use crate::__bytes_builder;
use crate::mariadb::{connection::Connection};
use crate::mariadb::protocol::packets::{eof::EofPacket, err::ErrPacket, ok::OkPacket, result_row::ResultRow};
use crate::mariadb::protocol::types::{ServerStatusFlag, Capabilities};
use crate::mariadb::connection::ConnContext;
use super::*;
#[runtime::test]
async fn it_decodes_result_set_packet() -> Result<(), Error> {
#[test]
fn it_decodes_result_set_packet() -> Result<(), Error> {
// TODO: Use byte string as input for test; this is a valid return from a mariadb.
#[rustfmt::skip]
let buf = __bytes_builder!(