Skip to content

Commit

Permalink
Test that the correct IVY repos were added.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Feb 11, 2022
1 parent ea54860 commit 6257d8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ private static void addIvyRepo(Project project, String name, String url, String
exclusiveContentRepository.filter(config -> config.includeGroup(group));
exclusiveContentRepository.forRepositories(repos.toArray(new IvyArtifactRepository[repos.size()]));
});
// set testCustomDistributionUrlProperty with url passed as parameter
if (project.findProperty("customDistributionUrl") != null) {
project.getExtensions().getExtraProperties().set("testCustomDistributionUrlProperty", url);
}
}

private static void addIvyRepo2(Project project, String name, String url, String group) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.opensearch.gradle.test.GradleUnitTestCase;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Project;
import org.gradle.api.internal.artifacts.repositories.DefaultIvyArtifactRepository;
import org.gradle.testfixtures.ProjectBuilder;

import java.io.File;
Expand Down Expand Up @@ -86,18 +87,27 @@ public void testCustomDistributionUrlForNull() {

public void testCustomDistributionUrlWithUrl() {
Project project = createProject(null, false);
String customUrl = "https://artifacts.opensearch.org";
String customUrl = "https://artifacts.opensearch.org/custom";
project.getExtensions().getExtraProperties().set("customDistributionUrl", customUrl);
DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class);
plugin.setupDistributions(project);
assertEquals(project.property("testCustomDistributionUrlProperty").toString(), customUrl);
assertEquals(4, project.getRepositories().size());
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads")).getUrl().toString(), customUrl);
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-snapshots")).getUrl().toString(), customUrl);
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-downloads")).getUrl().toString(), "https://artifacts-no-kpi.elastic.co");
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-snapshots")).getUrl().toString(), "https://snapshots-no-kpi.elastic.co");
}

public void testCustomDistributionUrlWithoutUrl() {
Project project = createProject(null, false);
DistributionDownloadPlugin plugin = project.getPlugins().getPlugin(DistributionDownloadPlugin.class);
plugin.setupDistributions(project);
assertFalse(project.hasProperty("testCustomDistributionUrlProperty"));
assertEquals(5, project.getRepositories().size());
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads")).getUrl().toString(), "https://artifacts.opensearch.org");
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-downloads2")).getUrl().toString(), "https://artifacts.opensearch.org");
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("opensearch-snapshots")).getUrl().toString(), "https://artifacts.opensearch.org");
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-downloads")).getUrl().toString(), "https://artifacts-no-kpi.elastic.co");
assertEquals(((DefaultIvyArtifactRepository) project.getRepositories().getAt("elasticsearch-snapshots")).getUrl().toString(), "https://snapshots-no-kpi.elastic.co");
}

public void testBadVersionFormat() {
Expand Down

0 comments on commit 6257d8e

Please sign in to comment.