diff --git a/crates/dagger-sdk/examples/iss-30-alt/main.rs b/crates/dagger-sdk/examples/iss-30-alt/main.rs deleted file mode 100644 index b523bf7..0000000 --- a/crates/dagger-sdk/examples/iss-30-alt/main.rs +++ /dev/null @@ -1,42 +0,0 @@ -#![feature(async_closure)] - -use dagger_sdk::{ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOpts}; - -static DOCKER_FILES: [&str; 3] = ["Dockerfile", "Dockerfile.alpine", "Dockerfile.distroless"]; -static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"]; - -#[tokio::main] -async fn main() -> eyre::Result<()> { - let client = dagger_sdk::connect().await?; - - let context = client.host().directory_opts( - ".", - HostDirectoryOpts { - exclude: Some(vec!["target", "client/node_modules", "client/build"]), - include: None, - }, - ); - - for file in DOCKER_FILES { - for platform in PLATFORMS { - let ref_ = client - .container_opts(QueryContainerOpts { - id: None, - platform: Some(platform.to_string().into()), - }) - .build_opts( - context.id().await?, - ContainerBuildOptsBuilder::default() - .dockerfile(file) - .build() - .unwrap(), - ) - .export("./test") - .await?; - - println!("published image to: {:#?}", ref_); - } - } - - Ok(()) -} diff --git a/crates/dagger-sdk/examples/iss-30/main.rs b/crates/dagger-sdk/examples/iss-30/main.rs deleted file mode 100644 index 9f7ce5c..0000000 --- a/crates/dagger-sdk/examples/iss-30/main.rs +++ /dev/null @@ -1,44 +0,0 @@ -#![feature(async_closure)] - -use dagger_sdk::{ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOptsBuilder}; - -static DOCKER_FILES: [&str; 3] = ["Dockerfile", "Dockerfile.alpine", "Dockerfile.distroless"]; -static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"]; - -#[tokio::main] -async fn main() -> eyre::Result<()> { - let client = dagger_sdk::connect().await?; - - let context = client.host().directory_opts( - ".", - HostDirectoryOpts { - exclude: Some(vec!["target", "client/node_modules", "client/build"]), - include: None, - }, - ); - - for file in DOCKER_FILES { - for platform in PLATFORMS { - let ref_ = client - .container_opts( - QueryContainerOptsBuilder::default() - .platform(platform) - .build() - .unwrap(), - ) - .build_opts( - context.id().await?, - ContainerBuildOptsBuilder::default() - .dockerfile(file) - .build() - .unwrap(), - ) - .export("./test") - .await?; - - println!("published image to: {:#?}", ref_); - } - } - - Ok(()) -} diff --git a/crates/dagger-sdk/test b/crates/dagger-sdk/test new file mode 100644 index 0000000..9bea041 Binary files /dev/null and b/crates/dagger-sdk/test differ diff --git a/crates/dagger-sdk/tests/issues/iss_30.rs b/crates/dagger-sdk/tests/issues/iss_30.rs new file mode 100644 index 0000000..67a98d3 --- /dev/null +++ b/crates/dagger-sdk/tests/issues/iss_30.rs @@ -0,0 +1,63 @@ +use dagger_sdk::{ + ContainerBuildOptsBuilder, HostDirectoryOpts, QueryContainerOpts, QueryContainerOptsBuilder, +}; + +static PLATFORMS: [&str; 2] = ["linux/arm64", "linux/x86_64"]; + +#[tokio::test] +async fn test_issue_30_alt() -> eyre::Result<()> { + let client = dagger_sdk::connect().await?; + + let context = client.host().directory_opts( + ".", + HostDirectoryOpts { + exclude: Some(vec!["target", "client/node_modules", "client/build"]), + include: None, + }, + ); + + for platform in PLATFORMS { + let ref_ = client + .container_opts(QueryContainerOpts { + id: None, + platform: Some(platform.to_string().into()), + }) + .from("alpine") + .export("./test") + .await?; + + println!("published image to: {:#?}", ref_); + } + + Ok(()) +} + +#[tokio::test] +async fn test_issue_30() -> eyre::Result<()> { + let client = dagger_sdk::connect().await?; + + let context = client.host().directory_opts( + ".", + HostDirectoryOpts { + exclude: Some(vec!["target", "client/node_modules", "client/build"]), + include: None, + }, + ); + + for platform in PLATFORMS { + let ref_ = client + .container_opts( + QueryContainerOptsBuilder::default() + .platform(platform) + .build() + .unwrap(), + ) + .from("alpine") + .export("./test") + .await?; + + println!("published image to: {:#?}", ref_); + } + + Ok(()) +} diff --git a/crates/dagger-sdk/tests/issues/mod.rs b/crates/dagger-sdk/tests/issues/mod.rs new file mode 100644 index 0000000..fa13322 --- /dev/null +++ b/crates/dagger-sdk/tests/issues/mod.rs @@ -0,0 +1 @@ +mod iss_30; diff --git a/crates/dagger-sdk/tests/mod.rs b/crates/dagger-sdk/tests/mod.rs index 701e78d..9611f64 100644 --- a/crates/dagger-sdk/tests/mod.rs +++ b/crates/dagger-sdk/tests/mod.rs @@ -1,3 +1,5 @@ +mod issues; + use dagger_sdk::{connect, ContainerExecOptsBuilder}; use pretty_assertions::assert_eq;