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
|
|
|
|
2023-02-19 21:37:54 +01:00
|
|
|
#[tokio::test]
|
|
|
|
async fn test_example_container() {
|
2023-02-20 10:10:42 +01:00
|
|
|
let client = connect().await.unwrap();
|
2023-02-05 23:44:06 +01:00
|
|
|
|
2023-02-19 17:43:12 +01:00
|
|
|
let alpine = client.container().from("alpine:3.16.2");
|
2023-02-05 23:44:06 +01:00
|
|
|
|
|
|
|
let out = alpine
|
2023-02-19 17:49:22 +01:00
|
|
|
.exec_opts(
|
2023-02-19 17:21:40 +01:00
|
|
|
ContainerExecOptsBuilder::default()
|
|
|
|
.args(vec!["cat", "/etc/alpine-release"])
|
|
|
|
.build()
|
|
|
|
.unwrap(),
|
2023-02-19 17:49:22 +01:00
|
|
|
)
|
2023-02-19 15:18:25 +01:00
|
|
|
.stdout()
|
2023-02-19 21:37:54 +01:00
|
|
|
.await
|
2023-02-19 15:18:25 +01:00
|
|
|
.unwrap();
|
2023-02-05 23:44:06 +01:00
|
|
|
|
2023-02-17 12:33:16 +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());
|
|
|
|
}
|