Skip to content

Instantly share code, notes, and snippets.

@grechaw
Created January 6, 2017 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grechaw/f9cf66b06b5368d2303f8537c3dbb90a to your computer and use it in GitHub Desktop.
Save grechaw/f9cf66b06b5368d2303f8537c3dbb90a to your computer and use it in GitHub Desktop.
This script simply takes a QA harness REST test and transforms it into a QConsole workspace so that you can run it interactively.
(: turn a QA Harness test file into a QConsole Workspace :)
declare namespace h = "http://marklogic.com/xdmp/harness";
let $QA_HOME := "/MarkLogic/git/qa-trunk"
let $source := ($QA_HOME || "/scripts/tests/rest-client-api-documents-06.xml")
=>xdmp:filesystem-file()
=>xdmp:unquote()
let $queries :=
for $test in $source/h:script/h:test
let $query-text := $test/h:query/text()
=>fn:replace("rest_api_test_port", "12345")
=>fn:replace("QA_HOME",$QA_HOME)
return
<query name="{$test/h:name}" mode="xquery">{$query-text}</query>
let $workspace := <export><workspace name="QA Harness Export">{$queries}</workspace></export>
return xdmp:save("/share/w.xml", $workspace)
@grechaw
Copy link
Author

grechaw commented Jan 6, 2017

The results of this particular example, once imported into QC, requires one XQuery module in the Modules database in order to run in QConsole. I installed it like this:

curl -X PUT -d@rest-client-api-common.xqy -Hcontent-type:application/xquery "http://localhost:8000/v1/documents?database=Modules&uri=/rest-client-api-common.xqy"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment