Skip to content

Commit

Permalink
#135 🐛 trailing slash enforcer break null/default URL during release …
Browse files Browse the repository at this point in the history
…process
  • Loading branch information
d-ryan-ashcraft committed May 14, 2024
1 parent a16d841 commit 18edbc9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ String getRepositoryUrl(boolean publishToDev) {
return addTrailingSlash(repoUrl);
}

private static String addTrailingSlash(String inputUrl) {
if (!inputUrl.endsWith("/")) {
static String addTrailingSlash(String inputUrl) {
if (StringUtils.isNotBlank(inputUrl) && !StringUtils.endsWith(inputUrl, "/")) {
// PEP-0694 likes a trailing slash:
inputUrl += "/";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ public void a_custom_push_dev_repository_url_path_of(String customPushDevReposit
deployMojo.devRepositoryUrlUploadSuffix = customPushDevRepositoryUrlPath;
}

@Given("a null URL")
public void a_null_url() {
deployMojo.devRepositoryUrl = null;
}

@Given("an empty URL")
public void an_empty_url() {
deployMojo.devRepositoryUrl = "";
}

@When("the Habushu deploy phase executes")
public void the_habushu_deploy_phase_executes() throws MojoExecutionException, MojoFailureException {
// do nothing
Expand All @@ -36,4 +46,22 @@ public void the_dev_repository_url_is(String expectedDevRepository) {
Assertions.assertEquals(expectedDevRepository, deployMojo.getRepositoryUrl(true), "Unexpected default dev repository url!");
}

@Then("the repository url of {string} contains a trailing slash")
public void the_repository_url_of_contains_a_trailing_slash(String expectedRepositoryUrl) {
String processedRepositoryUrl = deployMojo.addTrailingSlash(deployMojo.devRepositoryUrl);
Assertions.assertEquals(expectedRepositoryUrl, processedRepositoryUrl, "Unexpected repository url!");
Assertions.assertTrue(processedRepositoryUrl.endsWith("/"), "Missing trailing slash!");
}


@Then("the repository url is null")
public void the_repository_url_is_null() {
Assertions.assertNull(deployMojo.addTrailingSlash(deployMojo.devRepositoryUrl), "Expected null repository url!");
}

@Then("the repository url is empty")
public void the_repository_url_is_empty() {
Assertions.assertEquals("", deployMojo.addTrailingSlash(deployMojo.devRepositoryUrl), "Expected null repository url!");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,23 @@ Feature: Provides ability to push .dev versions to a different repository than r
| https://update.myrepo.com/ | | https://update.myrepo.com/ |
| https://update.myrepo.com | | https://update.myrepo.com/ |

Scenario Outline: Add trailing slash to URL for PEP-0694 compliance
Given a custom dev repository is configured to "<repositoryUrl>"
When the Habushu deploy phase executes
Then the repository url of "<finalRepositoryUrl>" contains a trailing slash

Examples:
| repositoryUrl | finalRepositoryUrl |
| http://test.pypi.org | http://test.pypi.org/ |
| http://test.pypi.org/ | http://test.pypi.org/ |
| https://update.myrepo.com | https://update.myrepo.com/ |

Scenario: Ensure trailing slash handles default case where a null URL is passed to poetry for default handling without issue
Given a null URL
When the Habushu deploy phase executes
Then the repository url is null

Scenario: Ensure trailing slash handles default case where an empty URL is passed to poetry for default handling without issue
Given an empty URL
When the Habushu deploy phase executes
Then the repository url is empty

0 comments on commit 18edbc9

Please sign in to comment.