Skip to content

Commit

Permalink
Merge pull request #84 from bidesh/master
Browse files Browse the repository at this point in the history
GetJobDiff not ignoring non-existing portDefinitions
  • Loading branch information
msiebeneicher committed Mar 28, 2017
2 parents 7cd6942 + 197349a commit e4df7ab
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 4 deletions.
Expand Up @@ -156,6 +156,7 @@ public function getJobDiff($sJobName)
$_oRemoteEntity = $this->getEntitySetWithDefaults();
}

$this->preCompareModifications($_oLocalEntity, $_oRemoteEntity);
$_aNonIdenticalProps = $this->compareJobEntities(
$_oLocalEntity,
$_oRemoteEntity
Expand Down
Expand Up @@ -12,6 +12,7 @@

use Chapi\BusinessCase\Comparison\MarathonJobComparisonBusinessCase;
use Chapi\Entity\Marathon\AppEntity\HealthCheck;
use Chapi\Entity\Marathon\AppEntity\PortDefinition;
use Chapi\Entity\Marathon\MarathonAppEntity;
use ChapiTest\src\TestTraits\AppEntityTrait;
use Prophecy\Argument;
Expand Down Expand Up @@ -52,14 +53,14 @@ public function testGetLocalMissingJobsSuccess()
->willReturn($_aLocalEntities);

$oMarathonJobCompare = new MarathonJobComparisonBusinessCase(
$this->oLocalRepository->reveal(),
$this->oLocalRepository->reveal(),
$this->oRemoteRepository->reveal(),
$this->oDiffCompare->reveal()
);

$_aLocalMissingJobs = $oMarathonJobCompare->getLocalMissingJobs();

$this->assertEquals(1, count($_aLocalMissingJobs), 'Expected 1 job, got '. count($_aLocalMissingJobs));
$this->assertEquals(1, count($_aLocalMissingJobs), 'Expected 1 job, got ' . count($_aLocalMissingJobs));

$_sGotKey = $_aLocalMissingJobs[0];
$this->assertEquals("/main/id1", $_sGotKey, 'Expected ”/main/id1", received ' . $_sGotKey);
Expand Down Expand Up @@ -87,7 +88,7 @@ public function testGetRemoteMissingJobsSuccess()

$_aRemoteMissingJobs = $oMarathonJobCompare->getRemoteMissingJobs();

$this->assertEquals(1, count($_aRemoteMissingJobs), 'Expected 1 job, got '. count($_aRemoteMissingJobs));
$this->assertEquals(1, count($_aRemoteMissingJobs), 'Expected 1 job, got ' . count($_aRemoteMissingJobs));

$_sGotKey = $_aRemoteMissingJobs[0];
$this->assertEquals("/main/id1", $_sGotKey, 'Expected ”/main/id1", received ' . $_sGotKey);
Expand Down Expand Up @@ -124,11 +125,45 @@ public function testGetLocalJobUpdatesSuccess()

$_aUpdatedApps = $oMarathonJobCompare->getLocalJobUpdates();

$this->assertEquals(1, count($_aUpdatedApps), 'Expected 1 job, got '. count($_aUpdatedApps));
$this->assertEquals(1, count($_aUpdatedApps), 'Expected 1 job, got ' . count($_aUpdatedApps));

$this->assertEquals('/main/id2', $_aUpdatedApps[0], 'Expected "/main/id2", received ' . $_aUpdatedApps[0]);
}

public function testGetLocalUpdatesCallsPreCompareModification()
{
$_oLocalEntity = $this->getValidMarathonAppEntity('/main/id1');

$_oRemoteEntity = $this->getValidMarathonAppEntity('/main/id1');
$_oRemoteEntity->portDefinitions = new PortDefinition(["port" => 8080]);


$this->oLocalRepository
->getJobs()
->willReturn([$_oLocalEntity]);

$this->oRemoteRepository
->getJobs()
->willReturn([$_oRemoteEntity]);

$this->oRemoteRepository
->getJob(Argument::exact($_oRemoteEntity->getKey()))
->willReturn($_oRemoteEntity);


$oMarathonJobCompare = new MarathonJobComparisonBusinessCase(
$this->oLocalRepository->reveal(),
$this->oRemoteRepository->reveal(),
$this->oDiffCompare->reveal()
);

$_aGotDiff = $oMarathonJobCompare->getLocalJobUpdates('/main/id1');

$_aExpectedDiff = [];
$this->assertEquals($_aExpectedDiff, $_aGotDiff, "Expected diff doesn't matched recieved diff");

}

public function testGetJobDiffWithChangesInRemoteSuccess()
{
$_oLocalEntity = $this->getValidMarathonAppEntity('/main/id1');
Expand Down Expand Up @@ -180,6 +215,36 @@ public function testGetJobDiffWithChangesInRemoteSuccess()
$this->assertEquals($_aExpectedDiff, $_aGotDiff, "Expected diff doesn't matched recieved diff");
}

public function testGetJobDiffCallsPreCompareModification()
{
$_oLocalEntity = $this->getValidMarathonAppEntity('/main/id1');

$_oRemoteEntity = $this->getValidMarathonAppEntity('/main/id1');
$_oRemoteEntity->portDefinitions = new PortDefinition(["port" => 8080]);


$this->oLocalRepository
->getJob(Argument::exact($_oLocalEntity->getKey()))
->willReturn($_oLocalEntity);

$this->oRemoteRepository
->getJob(Argument::exact($_oRemoteEntity->getKey()))
->willReturn($_oRemoteEntity);


$oMarathonJobCompare = new MarathonJobComparisonBusinessCase(
$this->oLocalRepository->reveal(),
$this->oRemoteRepository->reveal(),
$this->oDiffCompare->reveal()
);

$_aGotDiff = $oMarathonJobCompare->getJobDiff('/main/id1');

$_aExpectedDiff = [];
$this->assertEquals($_aExpectedDiff, $_aGotDiff, "Expected diff doesn't matched recieved diff");

}

public function testIsJobAvailableSuccess()
{
$this->oLocalRepository
Expand Down

0 comments on commit e4df7ab

Please sign in to comment.