Skip to content

Commit

Permalink
Fix tests after NPM change
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith committed Dec 14, 2023
1 parent eece802 commit d8fe591
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void jsPlugins() throws Exception {
// Note: JettyFlightRoundTripTest is not the most minimal / appropriate bootstrapping for this test, but it is
// the most convenient since it has all of the necessary prerequisites
new Example123Registration().registerInto(component.registration());
testJsPluginExamples(true, true);
testJsPluginExamples(false, true, true);
}

@Test
Expand All @@ -71,7 +71,7 @@ public void jsPluginsFromManifest() throws Exception {
final Path manifestRoot = Path.of(Sentinel.class.getResource("examples").toURI());
new JsPluginsManifestRegistration(manifestRoot)
.registerInto(component.registration());
testJsPluginExamples(false, true);
testJsPluginExamples(false, false, true);
}

@Test
Expand All @@ -85,10 +85,11 @@ public void jsPluginsFromNpmPackages() throws Exception {
.registerInto(component.registration());
new JsPluginsNpmPackageRegistration(example2Root)
.registerInto(component.registration());
testJsPluginExamples(false, false);
testJsPluginExamples(true, true, false);
}

private void testJsPluginExamples(boolean example2IsLimited, boolean hasExample3) throws Exception {
private void testJsPluginExamples(boolean example1IsLimited, boolean example2IsLimited, boolean hasExample3)
throws Exception {
final HttpClient client = new HttpClient();
client.start();
try {
Expand All @@ -97,7 +98,7 @@ private void testJsPluginExamples(boolean example2IsLimited, boolean hasExample3
} else {
manifestTest12(client);
}
example1Tests(client);
example1Tests(client, example1IsLimited);
example2Tests(client, example2IsLimited);
if (hasExample3) {
example3Tests(client);
Expand All @@ -119,10 +120,16 @@ private void manifestTest123(HttpClient client) throws InterruptedException, Tim
"{\"plugins\":[{\"name\":\"@deephaven_test/example1\",\"version\":\"0.1.0\",\"main\":\"dist/index.js\"},{\"name\":\"@deephaven_test/example2\",\"version\":\"0.2.0\",\"main\":\"dist/index.js\"},{\"name\":\"@deephaven_test/example3\",\"version\":\"0.3.0\",\"main\":\"index.js\"}]}");
}

private void example1Tests(HttpClient client) throws InterruptedException, TimeoutException, ExecutionException {
assertOk(get(client, "js-plugins/@deephaven_test/example1/package.json"),
"application/json",
"{\"name\":\"@deephaven_test/example1\",\"version\":\"0.1.0\",\"main\":\"dist/index.js\",\"files\":[\"dist\"]}");
private void example1Tests(HttpClient client, boolean isLimited)
throws InterruptedException, TimeoutException, ExecutionException {
if (isLimited) {
assertThat(get(client, "js-plugins/@deephaven_test/example1/package.json").getStatus())
.isEqualTo(HttpStatus.NOT_FOUND_404);
} else {
assertOk(get(client, "js-plugins/@deephaven_test/example1/package.json"),
"application/json",
"{\"name\":\"@deephaven_test/example1\",\"version\":\"0.1.0\",\"main\":\"dist/index.js\",\"files\":[\"dist\"]}");
}

assertOk(
get(client, "js-plugins/@deephaven_test/example1/dist/index.js"),
Expand Down Expand Up @@ -151,15 +158,10 @@ private void example2Tests(HttpClient client, boolean isLimited)
"text/javascript",
"// example2/dist/index.js");

if (isLimited) {
assertThat(get(client, "js-plugins/@deephaven_test/example2/dist/index2.js").getStatus())
.isEqualTo(HttpStatus.NOT_FOUND_404);
} else {
assertOk(
get(client, "js-plugins/@deephaven_test/example2/dist/index2.js"),
"text/javascript",
"// example2/dist/index2.js");
}
assertOk(
get(client, "js-plugins/@deephaven_test/example2/dist/index2.js"),
"text/javascript",
"// example2/dist/index2.js");
}

private void example3Tests(HttpClient client) throws InterruptedException, TimeoutException, ExecutionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ private static JsPlugin example1() throws URISyntaxException {

private static JsPlugin example2() throws URISyntaxException {
final Path resourcePath = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example2").toURI());
final Path main = resourcePath.relativize(resourcePath.resolve("dist/index.js"));
final Path dist = resourcePath.relativize(resourcePath.resolve("dist"));
final Path main = dist.resolve("index.js");
return JsPlugin.builder()
.name("@deephaven_test/example2")
.version("0.2.0")
.main(main)
.path(resourcePath)
.paths(Paths.ofPrefixes(main))
.paths(Paths.ofPrefixes(dist))
.build();
}

Expand Down

0 comments on commit d8fe591

Please sign in to comment.