Skip to content

Commit

Permalink
simplify DockerTestRunner, remove useless exec function
Browse files Browse the repository at this point in the history
  • Loading branch information
VendettaReborn committed Mar 19, 2024
1 parent 4a692b9 commit 675d1f8
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions clash_lib/src/proxy/utils/test_utils/docker_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ use bollard::container::{Config, RemoveContainerOptions};
use bollard::secret::{HostConfig, Mount, PortBinding};
use bollard::Docker;

use bollard::exec::{CreateExecOptions, StartExecResults};
use bollard::image::CreateImageOptions;

use anyhow::Result;
use futures::{Future, StreamExt, TryStreamExt};
use futures::{Future, TryStreamExt};

pub struct DockerTestRunner {
instance: Docker,
Expand Down Expand Up @@ -40,34 +39,6 @@ impl DockerTestRunner {
})
}

#[allow(unused)]
pub async fn exec(&self, cmd: Vec<&str>) -> anyhow::Result<()> {
// non interactive
let exec = self
.instance
.create_exec(
&self.id,
CreateExecOptions {
attach_stdout: Some(true),
attach_stderr: Some(true),
cmd: Some(cmd),
..Default::default()
},
)
.await?
.id;
if let StartExecResults::Attached { mut output, .. } =
self.instance.start_exec(&exec, None).await?
{
while let Some(Ok(msg)) = output.next().await {
print!("{msg}");
}
return Ok(());
} else {
anyhow::bail!("failed to execute cmd")
}
}

// will make sure the container is cleaned up after the future is finished
pub async fn run_and_cleanup(
self,
Expand Down

0 comments on commit 675d1f8

Please sign in to comment.