Set up test harness and create MySQL container.
This commit is contained in:
parent
aa666c5487
commit
f7fcb22986
3 changed files with 1896 additions and 13 deletions
1883
Cargo.lock
generated
Normal file
1883
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -4,3 +4,5 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
testcontainers-modules = { version = "0.12", features = ["mysql"] }
|
||||||
|
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
|
|
24
src/lib.rs
24
src/lib.rs
|
@ -1,14 +1,12 @@
|
||||||
pub fn add(left: u64, right: u64) -> u64 {
|
#[tokio::test]
|
||||||
left + right
|
async fn test_mysql() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
}
|
use testcontainers_modules::{mysql, testcontainers::runners::AsyncRunner};
|
||||||
|
let mysql_instance = mysql::Mysql::default().start().await?;
|
||||||
#[cfg(test)]
|
#[allow(unused_variables)]
|
||||||
mod tests {
|
let mysql_url = format!(
|
||||||
use super::*;
|
"mysql://{}:{}/test",
|
||||||
|
mysql_instance.get_host().await?,
|
||||||
#[test]
|
mysql_instance.get_host_port_ipv4(3306).await?
|
||||||
fn it_works() {
|
);
|
||||||
let result = add(2, 2);
|
Ok(())
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue