Skip to content

Commit 7255f14

Browse files
quintesseandsel
authored andcommitted
Added some tests
1 parent 7f770c2 commit 7255f14

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

itests/docstest1.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//DOCS readme.md
3+
4+
import static java.lang.System.*;
5+
6+
public class docstest1 {
7+
public static void main(String... args) {
8+
out.println("Docs test 1"));
9+
}
10+
}

itests/docstest2.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
///usr/bin/env jbang "$0" "$@" ; exit $?
2+
//DOCS https://www.jbang.dev/documentation/guide/latest/faq.html
3+
4+
import static java.lang.System.*;
5+
6+
public class docstest1 {
7+
public static void main(String... args) {
8+
out.println("Docs test 2"));
9+
}
10+
}

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("docstest1.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("docstest2.java").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)