Skip to content

Commit

Permalink
Add test with --fresh and --repos
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini authored and quintesse committed Jun 22, 2022
1 parent d7c2a77 commit 35056e8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/test/java/dev/jbang/cli/TestRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -2065,4 +2065,42 @@ void testRunMissingScript() {
run.doCall();
});
}

@Test
void testReposWorksWithFresh() throws IOException {
File f = Util.getCwd().resolve("classpath_example.java").toFile();

String content = ""
+ "///usr/bin/env jbang \"$0\" \"$@\" ; exit $?\n"
+ "\n"
+ "//DEPS log4j:log4j:1.2.17\n"
+ "\n"
+ "import org.apache.log4j.Logger;\n"
+ "import org.apache.log4j.BasicConfigurator;\n"
+ "\n"
+ "import java.util.Arrays;\n"
+ "\n"
+ "class classpath_example {\n"
+ "\n"
+ " static final Logger logger = Logger.getLogger(classpath_example.class);\n"
+ "\n"
+ " public static void main(String[] args) {\n"
+ " BasicConfigurator.configure();\n"
+ " logger.info(\"Welcome to jbang\");\n"
+ " }\n"
+ "}";
Util.writeString(f.toPath(), content);

CommandLine.ParseResult pr = JBang .getCommandLine()
.parseArgs("run", "--fresh", "--repos", "mavencentral", f.getPath());
Run run = (Run) pr.subcommand().commandSpec().userObject();

RunContext ctx = run.getRunContext();
Code code = ctx.forResource(f.getPath());
code = run.prepareArtifacts(code, ctx);

String result = code.cmdGenerator(ctx).generate();

assertThat(result, containsString("log4j-1.2.17.jar"));
}
}

0 comments on commit 35056e8

Please sign in to comment.