dagger-rs/crates/dagger-sdk/tests/standard_apis/container.rs

63 lines
1.5 KiB
Rust
Raw Normal View History

2023-03-10 23:16:35 +01:00
use dagger_sdk::{connect, ContainerExecOptsBuilder};
2023-02-25 02:27:01 +01:00
use pretty_assertions::assert_eq;
2023-02-05 23:44:06 +01:00
#[tokio::test]
async fn test_example_container() {
let client = connect().await.unwrap();
2023-02-05 23:44:06 +01:00
let alpine = client.container().from("alpine:3.16.2");
2023-02-05 23:44:06 +01:00
let out = alpine
.exec_opts(
ContainerExecOptsBuilder::default()
.args(vec!["cat", "/etc/alpine-release"])
.build()
.unwrap(),
)
.stdout()
.await
.unwrap();
2023-02-05 23:44:06 +01:00
assert_eq!(out, "3.16.2\n".to_string())
2023-02-05 23:44:06 +01:00
}
2023-02-25 02:27:01 +01:00
#[tokio::test]
async fn test_container() {
let client = connect().await.unwrap();
let alpine = client.container().from("alpine:3.16.2");
let contents = alpine
.fs()
.file("/etc/alpine-release")
.contents()
.await
.unwrap();
assert_eq!(contents, "3.16.2\n".to_string());
let out = alpine
.exec_opts(
ContainerExecOptsBuilder::default()
.args(vec!["cat", "/etc/alpine-release"])
.build()
.unwrap(),
)
.stdout()
.await
.unwrap();
assert_eq!(out, "3.16.2\n".to_string());
let id = alpine.id().await.unwrap();
let contents = client
.container_opts(dagger_sdk::QueryContainerOpts {
id: Some(id),
platform: None,
})
.fs()
.file("/etc/alpine-release")
.contents()
.await
.unwrap();
assert_eq!(contents, "3.16.2\n".to_string());
}