Skip to content

Commit

Permalink
Fix #1 - issue where incorrect properties passed to build
Browse files Browse the repository at this point in the history
Was overriding the non-date properties of the deployment
as it cycled through and found older deployments
  • Loading branch information
matt-richardson committed May 6, 2016
1 parent ef3fbdf commit 5eb2ba1
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
env:
global:
- VERSION=2.4.0
- VERSION=2.4.1
- SHORT_COMMIT_SHA=$(git rev-parse --short HEAD)
- RELEASE_VERSION=$VERSION+build.$TRAVIS_BUILD_NUMBER.sha.$SHORT_COMMIT_SHA
- secure: FQU39qHnx9XMeB/DMN6AMBD18ReFfKdPyP6o/p3b7PA3Yr0JuvDb2y9YZmv7XFI1I6o/fEObHrq66sNXwQzBFmtj1RZMYbU9Me8BsqoxggHxK9jFsp7ycHn0KjCVGKqJLQ3GmyaaA9GDbYDq3hv3RkeCDzHYJ0UoiVYBX8SXtZaXvJv6geTbbY8SAKgLnr9J3+YXTLhN3hgCdBkLyWJpKyWtrgdFDr6q4OHpU5zN+NmzO5UBHO44A4Q0jcs15kwvgpk7miiwyOuXA7l7kcVQLukh19q3eVrMxBLpm8tH2aHgFQIvg9rIEF/1+jB337OTqFcwWrxZFq5Ryiu0QK3UDypP92zaqEsKzYcubs9GHoTMPmpxGGxOZMJ02iW5jB9BhicrhUuozGfUndmk+eSkjjUAtFISMDHIQlAapyck0uz+k+km00MdA9p1lHOLruCSrDrYj/8ncltprq2BjzASRY9N365XuYGgkP/j9Df/UXETXsEfGHvoAidu2Vo1CYtfp0LFL5XK+oXfXvk6ZS8/WV0LPume+wlm/pL4eT53rpNsu8N8LUJJXOPmqe9EvYQM8OoEmfJzuU9sDDZ2DOU9Kbu2rnPIj2dnmj5zEanEebVYGzxdlg6sIst3O+grlhZdLN5LhqN1S/xZjwOTC0V0DLE89K74X97vl39DV43oOPI=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ private void addOrUpdate(String environmentId, OctopusDate latestDeployment, Oct
targetDeployment = new Environment(environmentId, latestDeployment, latestSuccessfulDeployment, releaseId, deploymentId, version, projectId);
statusMap.add(targetDeployment);
} else {
if (targetDeployment.isLatestDeploymentOlderThan(latestDeployment)) {
targetDeployment.latestDeployment = latestDeployment;
}
if (targetDeployment.isLatestSuccessfulDeploymentOlderThen(latestSuccessfulDeployment)) {
targetDeployment.latestSuccessfulDeployment = latestSuccessfulDeployment;
}
targetDeployment.projectId = projectId;
targetDeployment.deploymentId = deploymentId;
targetDeployment.version = version;
targetDeployment.releaseId = releaseId;
if (targetDeployment.isLatestDeploymentOlderThan(latestDeployment)) {
targetDeployment.latestDeployment = latestDeployment;
targetDeployment.projectId = projectId;
targetDeployment.deploymentId = deploymentId;
targetDeployment.version = version;
targetDeployment.releaseId = releaseId;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void get_deployments_when_no_successful_deployments_on_first_page_of_resu
Assert.assertEquals(newEnvironments.size(), 1);
Environment environment = newEnvironments.getEnvironment("Environments-1");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 18, 1, 887), new OctopusDate(2016, 1, 21, 13, 35, 27, 179), "Releases-65", "Deployments-83", "0.0.1", "Projects-26"));
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 18, 1, 887), new OctopusDate(2016, 1, 21, 13, 35, 27, 179), "Releases-66", "Deployments-113", "0.0.2", "Projects-26"));
}

public void get_deployments_when_multiple_environments() throws Exception {
Expand All @@ -168,7 +168,7 @@ public void get_deployments_when_multiple_environments() throws Exception {
Assert.assertEquals(newEnvironments.size(), 2);
Environment environment = newEnvironments.getEnvironment("Environments-1");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 26, 14, 747), new OctopusDate(2016, 1, 21, 14, 25, 40, 247), "Releases-69", "Deployments-117", "0.0.1", "Projects-28"));
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 26, 14, 747), new OctopusDate(2016, 1, 21, 14, 25, 40, 247), "Releases-70", "Deployments-119", "0.0.2", "Projects-28"));
environment = newEnvironments.getEnvironment("Environments-21");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-21", new OctopusDate(2016, 1, 21, 14, 25, 53, 700), new OctopusDate(2016, 1, 21, 14, 25, 53, 700), "Releases-69", "Deployments-118", "0.0.1", "Projects-28"));
Expand Down Expand Up @@ -227,7 +227,7 @@ public void when_there_are_two_new_deployments_since_last_check_it_returns_only_
Assert.assertEquals(newEnvironments.size(), 2);
Environment environment = newEnvironments.getEnvironment("Environments-1");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 26, 14, 747), new OctopusDate(2016, 1, 21, 14, 25, 40, 247), "Releases-69", "Deployments-117", "0.0.1", "Projects-28"));
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 26, 14, 747), new OctopusDate(2016, 1, 21, 14, 25, 40, 247), "Releases-70", "Deployments-119", "0.0.2", "Projects-28"));
environment = newEnvironments.getEnvironment("Environments-21");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-21", new OctopusDate(2016, 1, 21, 14, 25, 53, 700), new OctopusDate(2016, 1, 21, 14, 25, 53, 700), "Releases-69", "Deployments-118", "0.0.1", "Projects-28"));
Expand All @@ -236,7 +236,7 @@ public void when_there_are_two_new_deployments_since_last_check_it_returns_only_
Assert.assertEquals(trimmedEnvironments.size(), 2);
environment = trimmedEnvironments.getEnvironment("Environments-1");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 26, 14, 747), new OctopusDate(2016, 1, 21, 14, 25, 40, 247), "Releases-69", "Deployments-117", "0.0.1", "Projects-28"));
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 26, 14, 747), new OctopusDate(2016, 1, 21, 14, 25, 40, 247), "Releases-70", "Deployments-119", "0.0.2", "Projects-28"));
environment = trimmedEnvironments.getEnvironment("Environments-21");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-21", new OctopusDate(2016, 1, 20, 14, 0, 0, 0), new OctopusDate(2016, 1, 20, 14, 0, 0, 0), "Releases-69", "Deployments-116", "0.0.1", "Projects-28"));
Expand All @@ -250,7 +250,7 @@ public void get_deployments_when_multiple_environments_with_most_recent_deployme
Assert.assertEquals(newEnvironments.size(), 2);
Environment environment = newEnvironments.getEnvironment("Environments-1");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 24, 30, 935), new OctopusDate(2016, 1, 21, 14, 24, 30, 935), "Releases-67", "Deployments-114", "0.0.1", "Projects-27"));
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 1, 21, 14, 24, 30, 935), new OctopusDate(2016, 1, 21, 14, 24, 30, 935), "Releases-68", "Deployments-116", "0.0.2", "Projects-27"));
environment = newEnvironments.getEnvironment("Environments-21");
Assert.assertNotNull(environment);
Assert.assertEquals(environment, new Environment("Environments-21", new OctopusDate(2016, 1, 21, 14, 24, 10, 872), new OctopusDate(2016, 1, 21, 14, 24, 10, 872), "Releases-67", "Deployments-115", "0.0.1", "Projects-27"));
Expand All @@ -267,6 +267,18 @@ public void get_deployments_when_project_has_many_deployments() throws Exception
Assert.assertEquals(environment, new Environment("Environments-1", new OctopusDate(2016, 3, 9, 22, 26, 43, 504), new NullOctopusDate(), "Releases-244", "Deployments-245", "0.0.31", "Projects-153"));
}

// public void get_deployments_when_XXXXXX() throws Exception {
// HttpContentProviderFactory contentProviderFactory = new FakeContentProviderFactory(octopusUrl, octopusApiKey);
// DeploymentsProviderImpl deploymentsProviderImpl = new DeploymentsProviderImpl(contentProviderFactory, new FakeAnalyticsTracker());
// final String oldData = "Environments-167;1970-01-01T00:00:00.000+00:00;1970-01-01T00:00:00.000+00:00;null;null;null;null|Environments-216;2016-05-06T06:24:17.277+00:00;2016-05-06T06:24:17.277+00:00;Releases-5143;Deployments-7367;1.2.0.73-Retry3;Projects-562|Environments-233;2016-05-01T23:00:33.676+00:00;2016-05-01T23:00:33.676+00:00;Releases-5143;Deployments-8405;1.2.0.73-Retry3;Projects-562|Environments-269;2016-05-03T09:45:56.329+00:00;2016-05-03T09:45:56.329+00:00;Releases-5143;Deployments-7368;1.2.0.73-Retry3;Projects-562|Environments-14;2016-04-01T14:15:29.044+00:00;2016-04-01T14:15:29.044+00:00;Releases-5143;Deployments-7392;1.2.0.73-Retry3;Projects-562|Environments-15;2016-04-07T09:07:53.041+00:00;2016-04-07T09:07:53.041+00:00;Releases-5143;Deployments-7491;1.2.0.73-Retry3;Projects-562|Environments-621;2016-04-07T10:57:53.346+00:00;2016-04-07T10:57:53.346+00:00;Releases-5143;Deployments-7960;1.2.0.73-Retry3;Projects-562|Environments-382;2016-05-06T06:43:17.001+00:00;2016-05-06T06:43:17.001+00:00;Releases-9093;Deployments-14231;1.2.159.0;Projects-562";
// Environments oldEnvironments = Environments.Parse(oldData);
//
// Environments newEnvironments = deploymentsProviderImpl.getDeployments("Projects-562", oldEnvironments);
// Environment environment = newEnvironments.getEnvironment("Environments-216");
// Assert.assertNotNull(environment);
// Assert.assertEquals(environment, new Environment("Environments-216", new OctopusDate(2016, 5, 6, 9, 42, 45, 373), new OctopusDate(2016, 5, 6, 9, 42, 45, 373), "Releases-9506", "Deployments-14972", "1.2.164.0", "Projects-562"));
// }

public void determine_outcome_of_fallback_handles_more_responses() {
HttpContentProviderFactory contentProviderFactory = new FakeContentProviderFactory(octopusUrl, octopusApiKey);
FakeAnalyticsTracker fakeAnalyticsTracker = new FakeAnalyticsTracker();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,40 +193,58 @@ public void add_or_update_with_multiple_deployments_adds_all() {
Assert.assertEquals(sut.toString(), newEnvironments.toString());
}

public void add_or_update_with_multiple_deployments_overwrites_if_latest_deployment_date_is_newer() {
public void add_or_update_with_multiple_deployments_overwrites_all_fields_if_latest_deployment_date_is_newer() {
Environments existingEnvironments = new Environments(new Environment("Environment-1", new OctopusDate(2016, 2, 28), new OctopusDate(2016, 2, 27), "a-different-release-id", "a-different-deployment-id", "a-different-version", "the-project-id"));

Environments newEnvironments = new Environments();
newEnvironments.addOrUpdate(new Environment("Environment-1", new OctopusDate(2016, 2, 29), new OctopusDate(2016, 2, 28), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
newEnvironments.addOrUpdate(new Environment("Environment-1", new OctopusDate(2016, 2, 29), new OctopusDate(2016, 2, 27), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
newEnvironments.addOrUpdate(new Environment("Environment-2", new OctopusDate(2016, 2, 28), new NullOctopusDate(), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));

Environments sut = new Environments(new Environment("Environment-1", new OctopusDate(2016, 2, 28), new OctopusDate(2016, 2, 28), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
sut.addOrUpdate(newEnvironments);
existingEnvironments.addOrUpdate(newEnvironments);

Assert.assertEquals(sut.getEnvironment("Environment-1").latestDeployment, new OctopusDate(2016, 2, 29));
Assert.assertEquals(sut.getEnvironment("Environment-1").latestSuccessfulDeployment, new OctopusDate(2016, 2, 28));
Environment result = existingEnvironments.getEnvironment("Environment-1");
Assert.assertEquals(result.latestDeployment, new OctopusDate(2016, 2, 29));
Assert.assertEquals(result.latestSuccessfulDeployment, new OctopusDate(2016, 2, 27));
Assert.assertEquals(result.releaseId, "the-release-id");
Assert.assertEquals(result.deploymentId, "the-deployment-id");
Assert.assertEquals(result.version, "the-version");
Assert.assertEquals(result.projectId, "the-project-id");
}

public void add_or_update_with_multiple_deployments_overwrites_if_latest_successful_deployment_date_is_newer() {
public void add_or_update_with_multiple_deployments_overwrites_latest_successful_date_only_if_latest_successful_deployment_date_is_newer() {
Environments existingEnvironments = new Environments(new Environment("Environment-1", new OctopusDate(2016, 2, 29), new OctopusDate(2016, 2, 27), "a-different-release-id", "a-different-deployment-id", "a-different-version", "the-project-id"));

Environments newEnvironments = new Environments();
newEnvironments.addOrUpdate(new Environment("Environment-1", new OctopusDate(2016, 2, 29), new OctopusDate(2016, 2, 29), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
newEnvironments.addOrUpdate(new Environment("Environment-2", new OctopusDate(2016, 2, 28), new NullOctopusDate(), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
newEnvironments.addOrUpdate(new Environment("Environment-1", new OctopusDate(2016, 2, 29), new OctopusDate(2016, 2, 28), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
newEnvironments.addOrUpdate(new Environment("Environment-2", new OctopusDate(2016, 2, 27), new NullOctopusDate(), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));

Environments sut = new Environments(new Environment("Environment-1", new OctopusDate(2016, 2, 28), new OctopusDate(2016, 2, 28), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
sut.addOrUpdate(newEnvironments);
existingEnvironments.addOrUpdate(newEnvironments);

Assert.assertEquals(sut.getEnvironment("Environment-1").latestDeployment, new OctopusDate(2016, 2, 29));
Assert.assertEquals(sut.getEnvironment("Environment-1").latestSuccessfulDeployment, new OctopusDate(2016, 2, 29));
Environment result = existingEnvironments.getEnvironment("Environment-1");
Assert.assertEquals(result.latestDeployment, new OctopusDate(2016, 2, 29));
Assert.assertEquals(result.latestSuccessfulDeployment, new OctopusDate(2016, 2, 28));
Assert.assertEquals(result.releaseId, "a-different-release-id");
Assert.assertEquals(result.deploymentId, "a-different-deployment-id");
Assert.assertEquals(result.version, "a-different-version");
Assert.assertEquals(result.projectId, "the-project-id");
}

public void add_or_update_with_multiple_deployments_doesnt_overwrite_if_dates_are_older() {
public void add_or_update_with_multiple_deployments_does_not_overwrite_if_dates_are_older() {
Environments existingEnvironments = new Environments(new Environment("Environment-1", new OctopusDate(2016, 2, 28), new OctopusDate(2016, 2, 28), "a-different-release-id", "a-different-deployment-id", "a-different-version", "the-project-id"));

Environments newEnvironments = new Environments();
newEnvironments.addOrUpdate(new Environment("Environment-1", new OctopusDate(2016, 2, 27), new OctopusDate(2016, 2, 27), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
newEnvironments.addOrUpdate(new Environment("Environment-2", new OctopusDate(2016, 2, 28), new NullOctopusDate(), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));

Environments sut = new Environments(new Environment("Environment-1", new OctopusDate(2016, 2, 28), new OctopusDate(2016, 2, 28), "the-release-id", "the-deployment-id", "the-version", "the-project-id"));
sut.addOrUpdate(newEnvironments);
existingEnvironments.addOrUpdate(newEnvironments);

Assert.assertEquals(sut.getEnvironment("Environment-1").latestDeployment, new OctopusDate(2016, 2, 28));
Assert.assertEquals(sut.getEnvironment("Environment-1").latestDeployment, new OctopusDate(2016, 2, 28));
Environment result = existingEnvironments.getEnvironment("Environment-1");
Assert.assertEquals(result.latestDeployment, new OctopusDate(2016, 2, 28));
Assert.assertEquals(result.latestSuccessfulDeployment, new OctopusDate(2016, 2, 28));
Assert.assertEquals(result.releaseId, "a-different-release-id");
Assert.assertEquals(result.deploymentId, "a-different-deployment-id");
Assert.assertEquals(result.version, "a-different-version");
Assert.assertEquals(result.projectId, "the-project-id");
}

public void add_or_update_with_single_deployment_that_is_null_does_not_add() {
Expand Down

0 comments on commit 5eb2ba1

Please sign in to comment.