Skip to content

Commit

Permalink
Make Compose run command command use the original file path if enviro…
Browse files Browse the repository at this point in the history
…nment is active
  • Loading branch information
jonathanpv committed Apr 4, 2023
1 parent cc03e3c commit ba1f01f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions vdev/src/testing/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl IntegrationTest {
}

struct Compose {
path: PathBuf,
original_path: PathBuf,
test_dir: PathBuf,
env: Environment,
#[cfg(unix)]
Expand All @@ -147,14 +147,14 @@ struct Compose {

impl Compose {
fn new(test_dir: PathBuf, env: Environment, network: String) -> Result<Option<Self>> {
let path: PathBuf = [&test_dir, Path::new("compose.yaml")].iter().collect();
let original_path: PathBuf = [&test_dir, Path::new("compose.yaml")].iter().collect();

match path.try_exists() {
Err(error) => Err(error).with_context(|| format!("Could not lookup {path:?}")),
match original_path.try_exists() {
Err(error) => Err(error).with_context(|| format!("Could not lookup {original_path:?}")),
Ok(false) => Ok(None),
Ok(true) => {
#[cfg(unix)]
let mut config = ComposeConfig::parse(&path)?;
let mut config = ComposeConfig::parse(&original_path)?;

// Inject the networks block
config.networks.insert(
Expand All @@ -178,7 +178,7 @@ impl Compose {
)?;

Ok(Some(Self {
path,
original_path,
test_dir,
env,
#[cfg(unix)]
Expand Down Expand Up @@ -209,11 +209,11 @@ impl Compose {
// needs to use the calculated path from the integration name instead of the nonexistent
// tempfile path. This is because `stop` doesn't go through the same logic as `start`
// and doesn't create a new tempfile before calling docker compose.
// If stop command needs to use some of the injected bits then we need to rebuild it
command.arg("--file");
if config.is_none() {
command.arg("--file");
command.arg(&self.path);
command.arg(&self.original_path);
} else {
command.arg("--file");
command.arg(self.temp_file.path());
}

Expand Down

0 comments on commit ba1f01f

Please sign in to comment.