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"
|
||||
|
||||
[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 {
|
||||
left + right
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
#[tokio::test]
|
||||
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?;
|
||||
#[allow(unused_variables)]
|
||||
let mysql_url = format!(
|
||||
"mysql://{}:{}/test",
|
||||
mysql_instance.get_host().await?,
|
||||
mysql_instance.get_host_port_ipv4(3306).await?
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue