1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
use crate::yozefu_testcontainer::YozefuTestContainer;
use std::{path::PathBuf, sync::LazyLock};
use testcontainers::ImageExt;
pub mod yozefu_testcontainer;
static CONTAINER: LazyLock<YozefuTestContainer> = LazyLock::new(YozefuTestContainer::default);
#[test]
fn success() -> Result<(), Box<dyn std::error::Error>> {
let container = CONTAINER.run(|image| image.with_cmd(["config"]))?;
assert!(container.exit_code() == 0);
Ok(())
}
#[test]
fn read_only_root_fs() -> Result<(), Box<dyn std::error::Error>> {
let container = CONTAINER.run(|image| {
image
.with_cmd(["config"])
.with_readonly_rootfs(true)
.with_user("ubuntu")
})?;
assert!(container.exit_code() != 0);
assert!(container.stderr().contains("Read-only file system"));
Ok(())
}
#[test]
fn log_file_defined_with_env_variable() -> Result<(), Box<dyn std::error::Error>> {
let log_file = PathBuf::from("/tmp/yozefu.log");
let container = CONTAINER.run(|image| {
image
.with_cmd(["config"])
.with_env_var("YOZEFU_LOG_FILE", log_file.display().to_string())
})?;
assert_eq!(
0,
container.exit_code(),
"Container stderr: {}",
container.stderr()
);
assert!(container.file_exist(log_file));
Ok(())
}
*/