Skip to content

Commit

Permalink
Fixing more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaize Kaye committed Jul 2, 2024
1 parent 4c4786d commit 215afb4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 6 additions & 4 deletions tests/DeployTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function testBasicRun() {
$lub = $this->createStub(LagoonUtilityBelt::class);
$lub->method("deployEnvironment")->willReturn("testBuildId");
$runnerArgs = new RunnerArgs();
$deploy = new Deploy($lub, $runnerArgs);
$deploy = new Deploy($lub, $runnerArgs, new DynamicEnvironment(), new DynamicEnvironment());
$this->expectNotToPerformAssertions();
$deploy->run([]);
}
Expand All @@ -37,7 +37,7 @@ public function testNoSubstitutionsInArgs() {
$runnerArgs->project = $args['project'];
$runnerArgs->environment = $args['environment'];

$deploy = new Deploy($lub, $runnerArgs);
$deploy = new Deploy($lub, $runnerArgs, new DynamicEnvironment());

$deploy->run($args);

Expand Down Expand Up @@ -68,10 +68,12 @@ public function testStandardTextualSubstitutionsInArgs() {
$runnerArgs->project = $args['project'];
$runnerArgs->environment = $args['environment'];

$deploy = new Deploy($lub, $runnerArgs);
$dynamicEnv = new DynamicEnvironment();

$deploy = new Deploy($lub, $runnerArgs, $dynamicEnv);

// Let's set up the basic text subs we want to do
Deploy::setVariable('LAGOON_BACKUPS_DISABLED', "false");
$dynamicEnv->setVariable('LAGOON_BACKUPS_DISABLED', "false");

$deploy->run($args);

Expand Down
16 changes: 10 additions & 6 deletions tests/StepParentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ public function testFillDynamicEnvironmentFromEnv() {
$envVarVal = uniqid();
putenv(sprintf("%s=%s", $envVarName, $envVarVal));

StepParent::fillDynamicEnvironmentFromEnv();
$dynamicEnv = new DynamicEnvironment();

$this->assertEquals(StepParent::getVariable($envVarName), $envVarVal);
$dynamicEnv->fillDynamicEnvironmentFromEnv();

$this->assertEquals($dynamicEnv->getVariable($envVarName), $envVarVal);

}

Expand All @@ -32,12 +34,13 @@ public function testSubstitutions() {
$lub = $this->createStub(LagoonUtilityBelt::class);
$lub->method("deployEnvironment")->willReturn("testBuildId");
$runnerArgs = new RunnerArgs();
$deployStep = new Deploy($lub, $runnerArgs);
$dynamicEnv = new DynamicEnvironment();
$deployStep = new Deploy($lub, $runnerArgs, $dynamicEnv);

$toSubString = "this should have {{ something }} here";
$expected = "this should have words here";

StepParent::setVariable("something", "words");
$dynamicEnv->setVariable("something", "words");

$this->assertEquals($expected, $deployStep->doTextSubstitutions($toSubString));

Expand All @@ -63,9 +66,10 @@ public function testJSONPAYLOADFILL() {
// this looks like {"fullrun":"yes"}
putenv("JSON_PAYLOAD=eyJmdWxscnVuIjoieWVzIn0=");

StepParent::fillDynamicEnvironmentFromEnv();
$dynamicEnvironment = new DynamicEnvironment();
$dynamicEnvironment->fillDynamicEnvironmentFromEnv();

$this->assertEquals(StepParent::getVariable("fullrun"), "yes");
$this->assertEquals($dynamicEnvironment->getVariable("fullrun"), "yes");

}

Expand Down

0 comments on commit 215afb4

Please sign in to comment.