Test-driven Development on MarkLogic
-
Upload
jake-trent -
Category
Technology
-
view
476 -
download
3
description
Transcript of Test-driven Development on MarkLogic
declare function testFeature() {
let $actual := feature:doFeature()
(: assert feature condition :)
};
declare function doFeature() {
() (: todo: impl :)
};
declare function doFeature() {
let $output := lotsOfLogic()
return $output
};
import module namespace build = “b” at “/build.xqy”;
declare function testBuildXml() {
let $actual := b:buildXml()
(: assert only xml is well-built :)
};
import module namespace translate = “t” at “/transl8.xqy”;
declare function testAddTranslateFlags() {
let $actual := t:addTranslateFlags()
(: assert only that translation flags added correctly :)
};
import module namespace build = “b” at “/build.xqy”;
declare function buildXml_condition1() {
(: ... :)
};
declare function buildXml_condition2() {
(: ... :)
};
(: etc. :)
declare function bizLogic($input as element()*) {
(: ... :)
};
import module namespace logic = “logic” at “/logic.xqy”;
declare function bizLogic_emptyInput() {
(: ... :)
};
declare function bizLogic_oneInput() {
(: ... :)
};
declare function bizLogic_manyInput() {
(: ... :)
};
declare function bizLogic($input as element()*) {
(: ... :)
};
import module namespace logic = “logic” at “/logic.xqy”;
declare function bizLogic_insufficientInput() {
(: ... :)
};
declare function bizLogic_malformedInput() {
(: ... :)
};
declare function businessLogic($input) {
let $moreInput := /more-input[@attr eq $input]
let $returnVal :=
for $item in $moreInput
let $details := /detail[@id eq $item/id]
return if ($details/thing eq
xdmp:get-request-field(“thing-id”)) then
$details
else ()
return if (fn:exists($returnVal)) then
let $audit :=
xdmp:document-insert(“/latest.xml”, element ok {})
return $returnVal
else
xdmp:redirect-response(“/empty.xqy”);
};
declare function businessLogic($input) {
let $moreInput := /more-input[@attr eq $input]
let $returnVal :=
for $item in $moreInput
let $details := /detail[@id eq $item/id]
return if ($details/thing eq
xdmp:get-request-field(“thing-id”)) then
$details
else ()
return if (fn:exists($returnVal)) then
let $audit :=
xdmp:document-insert(“/latest.xml”, element ok {})
return $returnVal
else
xdmp:redirect-response(“/empty.xqy”);
};
xdmp:get-request-field(“var”)
xdmp:redirect-response(“/page.xqy”)
xdmp:document-insert(“/trades.xml”, element beads {})
fn:collection()/dances/rain
declare function feature() {
let $filter := xdmp:get-request-field(“filter”)
let $input := fn:collection()/data[@attr eq $filter]
let $result := businessLogic($input)
let $persist := xdmp:document-insert(“/doc.xml”, $result)
return xdmp:redirect-response(“complete.xqy”)
};
declare function feature() {
let $filter := xdmp:get-request-field(“filter”)
let $input := fn:collection()/data[@attr eq $filter]
let $result := businessLogic($input)
let $persist := xdmp:document-insert(“/doc.xml”, $result)
return xdmp:redirect-response(“complete.xqy”)
};
Green Ferrari Front (modified) http://www.flickr.com/photos/zouny/5054032055/ Design By Zouny's photostream Green Ferrari Side (modified) http://www.flickr.com/photos/zouny/5054024045/ Design By Zouny's photostream Belay http://www.flickr.com/photos/picsbycam/5173647461/ Cameron Cassan's photostream Thinker http://www.flickr.com/photos/garysoup/2705102139/ Gary Soup's photostream Clean Up http://www.flickr.com/photos/emilyrides/5188289325/lightbox/ emilydickinsonridesabmx's photostream Elephant http://www.flickr.com/photos/greenboots76/2924276160/ Henry Brett's photostream Chihuahua http://www.flickr.com/photos/62337512@N00/3727104807/ apdk's photostream Angry Dog http://www.flickr.com/photos/javiercito/2083111412/lightbox/ Javiercit0's photostream Clean up Pet http://www.flickr.com/photos/pointshoot/1144799868/ Eddie~S' photostream Hugging Fingers http://www.flickr.com/photos/ganesha_isis/4439563089/ ganesha.isis' photostream Fail Whale http://www.flickr.com/photos/coletivomambembe/3882172324/ Coletivo Mambembe's photostream Road Runner http://www.flickr.com/photos/snowpeak/4815685925/ snowpeak's photostream Keyboard Sleep http://www.flickr.com/photos/ytruly/1718468702/ YTruly's photostream Winding Road http://www.flickr.com/photos/dominicspics/422146490/ Dominic's pics' photostream
Neon Pipes http://www.flickr.com/photos/krossbow/3619931451/ krossbow's photostream - CC Attribution license Calculator http://www.flickr.com/photos/scoobay/2463236523/ Scoobay's photostream Water Droplet http://www.flickr.com/photos/shannonkringen/4680455907/ shannonkringen's photostream Decoupled http://www.flickr.com/photos/daquellamanera/2213902727/ Daquella manera's photostream Pointing Caterpillar http://www.flickr.com/photos/pinkstockphotos/5266977224/ PinkStock Photos!'s photostream Multiplication http://www.flickr.com/photos/somegeekintn/4048155967/ somegeekintn's photostream Cliff http://www.flickr.com/photos/elsie/144702426/ Elsie esq.'s photostream Pig Egg http://www.flickr.com/photos/katerha/5423107783/ katerha's photostream Spaghetti Noodle http://www.flickr.com/photos/pinksherbet/2201247567/ Pink Sherbet Photography's photostream Girl Eating Spaghetti http://www.flickr.com/photos/pinksherbet/5008273559/ Pink Sherbet Photography's photostream Camoflauge Lizard http://www.flickr.com/photos/lofink/4453281926/ dlofink's photostream Salute Flag http://www.flickr.com/photos/soldiersmediacenter/3920702814/ The U.S. Army's photostream Call on Beach http://www.flickr.com/photos/zitona/2268296925/ » Zitona «'s photostream
All Creative Commons 2.0 Attribution License unless otherwise noted
Indian Chief http://www.flickr.com/photos/boston_public_library/4100786887/in/photostream/ Boston Public Library's photostream Ninja Turtle http://www.flickr.com/photos/86805724@N00/1581833575/ ianmalcm's photostream Phone Booth http://www.flickr.com/photos/bexwalton/4204409348/ Bex.Walton's photostream Picasso http://www.flickr.com/photos/oddsock/101164507/ oddsock's photostream Suit http://www.flickr.com/photos/pss/4830803189/ Paul Stevenson's photostream Underwater http://www.flickr.com/photos/andreweick/4000567498/in/photostream/ AndrewEick's photostream Spider Tunnel http://www.flickr.com/photos/b1gw1ght/900924265/ b1gw1ght's photostream Safety Net http://www.flickr.com/photos/iamchadhearmesnore/3629410556/ iamchad's photostream Black Box http://www.flickr.com/photos/amagill/34762677/ AMagill's photostream The Sweded By David Quinn, used with permission Red Ferrari Engine http://www.flickr.com/photos/49889874@N05/5027004240/ marc falardeau's photostream Kodak Roll http://www.flickr.com/photos/picsbycam/4550970565/in/photostream/ Cameron Cassan's photostream Gnuolane Free font http://typodermicfonts.com Free for personal and commercial use