Skip to content

Commit bffa14b

Browse files
committed
Added some tests
1 parent 501c41b commit bffa14b

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

itests/helloworld.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//RUNTIME_OPTIONS -Dfoo=bar "-Dbar=aap noot mies"
55
//MANIFEST foo bar=baz baz=${bazprop:nada}
66

7+
//DOCS readme.md
8+
79
import static java.lang.System.*;
810

911
public class helloworld {

itests/helloworld.jsh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
///usr/bin/env jbang "$0" "$@" ; exit $?
22

3+
//DOCS https://www.jbang.dev/documentation/guide/latest/faq.html
4+
35
System.out.println("Hello " + (args.length>0?args[0]:"World"));
46

57
/exit

src/test/java/dev/jbang/cli/TestInfo.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.hamcrest.MatcherAssert.assertThat;
44
import static org.hamcrest.Matchers.*;
55

6+
import java.net.URI;
67
import java.nio.file.Paths;
78
import java.util.Collection;
89

@@ -162,4 +163,22 @@ void testInfoStarSources() {
162163
// assertThat(info.mainClass, equalTo("helloworld"));
163164
assertThat(info.resolvedDependencies, empty());
164165
}
166+
167+
@Test
168+
void testInfoDocsFile() {
169+
String src = examplesTestFolder.resolve("helloworld.java").toString();
170+
CommandLine.ParseResult pr = JBang.getCommandLine().parseArgs("info", "docs", src);
171+
Docs docs = (Docs) pr.subcommand().subcommand().commandSpec().userObject();
172+
URI uri = docs.getDocsUri();
173+
assertThat(uri.toString(), endsWith("/itests/readme.md"));
174+
}
175+
176+
@Test
177+
void testInfoDocsUrl() {
178+
String src = examplesTestFolder.resolve("helloworld.jsh").toString();
179+
CommandLine.ParseResult pr = JBang.getCommandLine().parseArgs("info", "docs", src);
180+
Docs docs = (Docs) pr.subcommand().subcommand().commandSpec().userObject();
181+
URI uri = docs.getDocsUri();
182+
assertThat(uri.toString(), equalTo("https://www.jbang.dev/documentation/guide/latest/faq.html"));
183+
}
165184
}

0 commit comments

Comments
 (0)