Skip to content

Commit 0c180b2

Browse files
authored
Merge pull request #193 from BillFarber/feature/GetTestPath
DEVEXP-549: Get path for test data
2 parents 84fb510 + b3c4937 commit 0c180b2

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
xquery version "1.0-ml";
2+
3+
module namespace url-lib = "http://marklogic.com/url-lib";
4+
5+
import module namespace test = "http://marklogic.com/test" at "/test/test-controller.xqy", "/test/test-helper.xqy";
6+
7+
declare function url-lib:call-get-test-data-directory-uri($caller as xs:string) as xs:string
8+
{
9+
test:get-test-data-directory-uri($caller)
10+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
xquery version "1.0-ml";
2+
3+
import module namespace test = "http://marklogic.com/test" at "/test/test-controller.xqy", "/test/test-helper.xqy";
4+
import module namespace url-lib = "http://marklogic.com/url-lib" at "/test/suites/Test Suites/lib/uri-lib.xqy";
5+
6+
(
7+
test:assert-equal("/test/suites/Test Suites/test-data/", test:get-test-data-directory-uri(test:get-caller())),
8+
test:assert-equal("/test/suites/Test Suites/test-data/", url-lib:call-get-test-data-directory-uri(test:get-caller()))
9+
)

marklogic-unit-test-modules/src/main/ml-modules/root/test/test-helper.xqy

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ declare variable $test:__LINE__ as xs:int :=
4444

4545
declare variable $test:__CALLER_FILE__ := test:get-caller();
4646

47+
(:
48+
: Returns a URI identifying the directory that contains any test data files associated with the test module that invokes this.
49+
:)
50+
declare function test:get-test-data-directory-uri($caller-path as xs:string) as xs:string
51+
{
52+
fn:replace(
53+
fn:concat(
54+
cvt:basepath($caller-path), "/test-data/"),
55+
"//", "/")
56+
};
57+
4758
declare function test:get-caller()
4859
as xs:string
4960
{

0 commit comments

Comments
 (0)