Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/test/java/dev/jbang/cli/TestAlias.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,44 @@ void testGetAliasLoop() throws IOException {

}

@Test
void testGetAliasFromLocalCatalog() throws IOException {
Path aliasesFile = jbangTempDir.resolve("aliases.json");
Files.write(aliasesFile, aliases.getBytes());

String cat = "{\n" +
" \"catalogs\": {\n" +
" \"local\": {\n" +
" \"catalog-ref\": \"" + aliasesFile + "\"\n" +
" }\n" +
" }\n" +
"}";
Path catFile = jbangTempDir.resolve(Catalog.JBANG_CATALOG_JSON);
Files.write(catFile, cat.getBytes());

assertThat(Alias.get("one@local"), notNullValue());
assertThat(Alias.get("one"), notNullValue());
}

@Test
void testGetAliasFromImplicitCatalog() throws IOException {
Path catFile = jbangTempDir.resolve(Catalog.JBANG_CATALOG_JSON);
Util.deletePath(catFile, true);
Path aliasesFile = jbangTempDir.resolve("aliases.json");
Files.write(aliasesFile, aliases.getBytes());

String cat = "{\n" +
" \"catalogs\": {\n" +
" \"local\": {\n" +
" \"catalog-ref\": \"" + aliasesFile + "\"\n" +
" }\n" +
" }\n" +
"}";
Path implicitCatFile = Settings.getUserImplicitCatalogFile();
Files.write(implicitCatFile, cat.getBytes());

assertThat(Alias.get("one@local"), notNullValue());
assertThat(Alias.get("one"), nullValue());
}

}
40 changes: 40 additions & 0 deletions src/test/java/dev/jbang/cli/TestTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,44 @@ void testAddWithMultipleComplexProperties() throws IOException {
entry("second-test-key", new TemplateProperty(
"This is another description for the second property key", "Non-Blocker"))));
}

@Test
void testGetTemplateFromLocalCatalog() throws IOException {
Path templatesFile = jbangTempDir.resolve("templates.json");
Files.write(templatesFile, templates.getBytes());

String cat = "{\n" +
" \"catalogs\": {\n" +
" \"local\": {\n" +
" \"catalog-ref\": \"" + templatesFile + "\"\n" +
" }\n" +
" }\n" +
"}";
Path catFile = jbangTempDir.resolve(Catalog.JBANG_CATALOG_JSON);
Files.write(catFile, cat.getBytes());

assertThat(Template.get("one@local"), notNullValue());
assertThat(Template.get("one"), notNullValue());
}

@Test
void testGetAliasFromImplicitCatalog() throws IOException {
Path catFile = jbangTempDir.resolve(Catalog.JBANG_CATALOG_JSON);
Util.deletePath(catFile, true);
Path templatesFile = jbangTempDir.resolve("templates.json");
Files.write(templatesFile, templates.getBytes());

String cat = "{\n" +
" \"catalogs\": {\n" +
" \"local\": {\n" +
" \"catalog-ref\": \"" + templatesFile + "\"\n" +
" }\n" +
" }\n" +
"}";
Path implicitCatFile = Settings.getUserImplicitCatalogFile();
Files.write(implicitCatFile, cat.getBytes());

assertThat(Template.get("one@local"), notNullValue());
assertThat(Template.get("one"), nullValue());
}
}
Loading