Fossil SCM
added test for /json/wiki/get.
Commit
2b7edce38d7b11e55b9418117a648179e0958bd4
Parent
e8fe84bc2c9a286…
1 file changed
+18
-4
+18
-4
| --- ajax/i-test/rhino-test.js | ||
| +++ ajax/i-test/rhino-test.js | ||
| @@ -1,10 +1,11 @@ | ||
| 1 | 1 | var TestApp = { |
| 2 | 2 | serverUrl: |
| 3 | - 'http://localhost:8080' | |
| 3 | + //'http://localhost:8080' | |
| 4 | 4 | //'http://fjson/cgi-bin/fossil-json.cgi' |
| 5 | 5 | //'http://192.168.1.62:8080' |
| 6 | + 'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi' | |
| 6 | 7 | , |
| 7 | 8 | verbose:true, |
| 8 | 9 | wiki:{} |
| 9 | 10 | }; |
| 10 | 11 | (function bootstrap() { |
| @@ -17,10 +18,11 @@ | ||
| 17 | 18 | load(includes[i]); |
| 18 | 19 | } |
| 19 | 20 | WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino; |
| 20 | 21 | TestApp.fossil = new FossilAjaj({ |
| 21 | 22 | asynchronous:false, /* rhino-based impl doesn't support async or timeout. */ |
| 23 | + timeout:0, | |
| 22 | 24 | url:TestApp.serverUrl, |
| 23 | 25 | beforeSend:function(req,opt){ |
| 24 | 26 | if(!TestApp.verbose) return; |
| 25 | 27 | print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt)); |
| 26 | 28 | if(req) print("Request envelope="+WhAjaj.stringify(req)); |
| @@ -124,14 +126,17 @@ | ||
| 124 | 126 | |
| 125 | 127 | function testAnonymousLogin(){ |
| 126 | 128 | TestApp.fossil.login(); |
| 127 | 129 | assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken); |
| 128 | 130 | assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName); |
| 131 | + TestApp.fossil.userName = null; | |
| 132 | + TestApp.fossil.whoami('/json/whoami'); | |
| 133 | + assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName); | |
| 129 | 134 | } |
| 130 | 135 | testAnonymousLogin.description = 'Perform anonymous login.'; |
| 131 | 136 | |
| 132 | -function testAnonWikiList(){ | |
| 137 | +function testAnonWiki(){ | |
| 133 | 138 | TestApp.fossil.sendCommand('/json/wiki/list',undefined,{ |
| 134 | 139 | beforeSend:function(req,opt){ |
| 135 | 140 | TestApp.fossil.ajaj.options.beforeSend(req,opt); |
| 136 | 141 | assert( req && (req.authToken==TestApp.fossil.authToken), 'Request envelope contains expected authToken.' ); |
| 137 | 142 | }, |
| @@ -140,12 +145,21 @@ | ||
| 140 | 145 | assert( (typeof [] === typeof resp.payload) && resp.payload.length, |
| 141 | 146 | "Wiki list seems to be okay."); |
| 142 | 147 | TestApp.wiki.list = resp.payload; |
| 143 | 148 | } |
| 144 | 149 | }); |
| 150 | + TestApp.fossil.sendCommand('/json/wiki/get',{ | |
| 151 | + page:TestApp.wiki.list[0] | |
| 152 | + },{ | |
| 153 | + onResponse:function(resp,req){ | |
| 154 | + assertResponseOK(resp); | |
| 155 | + assert(resp.payload.name == TestApp.wiki.list[0], "Fetched page name matches expectations."); | |
| 156 | + print("Got first wiki page: "+WhAjaj.stringify(resp.payload)); | |
| 157 | + } | |
| 158 | + }); | |
| 145 | 159 | } |
| 146 | -testAnonWikiList.description = 'Fetch wiki list as anonymous user.'; | |
| 160 | +testAnonWiki.description = 'Fetch wiki list as anonymous user.'; | |
| 147 | 161 | |
| 148 | 162 | function testAnonLogout(){ |
| 149 | 163 | TestApp.fossil.logout({ |
| 150 | 164 | onResponse:function(resp,req){ |
| 151 | 165 | assertResponseOK(resp); |
| @@ -162,11 +176,11 @@ | ||
| 162 | 176 | (function runAllTests(){ |
| 163 | 177 | var testList = [ |
| 164 | 178 | testHAI, |
| 165 | 179 | testIAmNobody, |
| 166 | 180 | testAnonymousLogin, |
| 167 | - testAnonWikiList, | |
| 181 | + testAnonWiki, | |
| 168 | 182 | testAnonLogout |
| 169 | 183 | ]; |
| 170 | 184 | var i, f; |
| 171 | 185 | for( i = 0; i < testList.length; ++i ){ |
| 172 | 186 | f = testList[i]; |
| 173 | 187 |
| --- ajax/i-test/rhino-test.js | |
| +++ ajax/i-test/rhino-test.js | |
| @@ -1,10 +1,11 @@ | |
| 1 | var TestApp = { |
| 2 | serverUrl: |
| 3 | 'http://localhost:8080' |
| 4 | //'http://fjson/cgi-bin/fossil-json.cgi' |
| 5 | //'http://192.168.1.62:8080' |
| 6 | , |
| 7 | verbose:true, |
| 8 | wiki:{} |
| 9 | }; |
| 10 | (function bootstrap() { |
| @@ -17,10 +18,11 @@ | |
| 17 | load(includes[i]); |
| 18 | } |
| 19 | WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino; |
| 20 | TestApp.fossil = new FossilAjaj({ |
| 21 | asynchronous:false, /* rhino-based impl doesn't support async or timeout. */ |
| 22 | url:TestApp.serverUrl, |
| 23 | beforeSend:function(req,opt){ |
| 24 | if(!TestApp.verbose) return; |
| 25 | print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt)); |
| 26 | if(req) print("Request envelope="+WhAjaj.stringify(req)); |
| @@ -124,14 +126,17 @@ | |
| 124 | |
| 125 | function testAnonymousLogin(){ |
| 126 | TestApp.fossil.login(); |
| 127 | assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken); |
| 128 | assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName); |
| 129 | } |
| 130 | testAnonymousLogin.description = 'Perform anonymous login.'; |
| 131 | |
| 132 | function testAnonWikiList(){ |
| 133 | TestApp.fossil.sendCommand('/json/wiki/list',undefined,{ |
| 134 | beforeSend:function(req,opt){ |
| 135 | TestApp.fossil.ajaj.options.beforeSend(req,opt); |
| 136 | assert( req && (req.authToken==TestApp.fossil.authToken), 'Request envelope contains expected authToken.' ); |
| 137 | }, |
| @@ -140,12 +145,21 @@ | |
| 140 | assert( (typeof [] === typeof resp.payload) && resp.payload.length, |
| 141 | "Wiki list seems to be okay."); |
| 142 | TestApp.wiki.list = resp.payload; |
| 143 | } |
| 144 | }); |
| 145 | } |
| 146 | testAnonWikiList.description = 'Fetch wiki list as anonymous user.'; |
| 147 | |
| 148 | function testAnonLogout(){ |
| 149 | TestApp.fossil.logout({ |
| 150 | onResponse:function(resp,req){ |
| 151 | assertResponseOK(resp); |
| @@ -162,11 +176,11 @@ | |
| 162 | (function runAllTests(){ |
| 163 | var testList = [ |
| 164 | testHAI, |
| 165 | testIAmNobody, |
| 166 | testAnonymousLogin, |
| 167 | testAnonWikiList, |
| 168 | testAnonLogout |
| 169 | ]; |
| 170 | var i, f; |
| 171 | for( i = 0; i < testList.length; ++i ){ |
| 172 | f = testList[i]; |
| 173 |
| --- ajax/i-test/rhino-test.js | |
| +++ ajax/i-test/rhino-test.js | |
| @@ -1,10 +1,11 @@ | |
| 1 | var TestApp = { |
| 2 | serverUrl: |
| 3 | //'http://localhost:8080' |
| 4 | //'http://fjson/cgi-bin/fossil-json.cgi' |
| 5 | //'http://192.168.1.62:8080' |
| 6 | 'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi' |
| 7 | , |
| 8 | verbose:true, |
| 9 | wiki:{} |
| 10 | }; |
| 11 | (function bootstrap() { |
| @@ -17,10 +18,11 @@ | |
| 18 | load(includes[i]); |
| 19 | } |
| 20 | WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino; |
| 21 | TestApp.fossil = new FossilAjaj({ |
| 22 | asynchronous:false, /* rhino-based impl doesn't support async or timeout. */ |
| 23 | timeout:0, |
| 24 | url:TestApp.serverUrl, |
| 25 | beforeSend:function(req,opt){ |
| 26 | if(!TestApp.verbose) return; |
| 27 | print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt)); |
| 28 | if(req) print("Request envelope="+WhAjaj.stringify(req)); |
| @@ -124,14 +126,17 @@ | |
| 126 | |
| 127 | function testAnonymousLogin(){ |
| 128 | TestApp.fossil.login(); |
| 129 | assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken); |
| 130 | assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName); |
| 131 | TestApp.fossil.userName = null; |
| 132 | TestApp.fossil.whoami('/json/whoami'); |
| 133 | assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName); |
| 134 | } |
| 135 | testAnonymousLogin.description = 'Perform anonymous login.'; |
| 136 | |
| 137 | function testAnonWiki(){ |
| 138 | TestApp.fossil.sendCommand('/json/wiki/list',undefined,{ |
| 139 | beforeSend:function(req,opt){ |
| 140 | TestApp.fossil.ajaj.options.beforeSend(req,opt); |
| 141 | assert( req && (req.authToken==TestApp.fossil.authToken), 'Request envelope contains expected authToken.' ); |
| 142 | }, |
| @@ -140,12 +145,21 @@ | |
| 145 | assert( (typeof [] === typeof resp.payload) && resp.payload.length, |
| 146 | "Wiki list seems to be okay."); |
| 147 | TestApp.wiki.list = resp.payload; |
| 148 | } |
| 149 | }); |
| 150 | TestApp.fossil.sendCommand('/json/wiki/get',{ |
| 151 | page:TestApp.wiki.list[0] |
| 152 | },{ |
| 153 | onResponse:function(resp,req){ |
| 154 | assertResponseOK(resp); |
| 155 | assert(resp.payload.name == TestApp.wiki.list[0], "Fetched page name matches expectations."); |
| 156 | print("Got first wiki page: "+WhAjaj.stringify(resp.payload)); |
| 157 | } |
| 158 | }); |
| 159 | } |
| 160 | testAnonWiki.description = 'Fetch wiki list as anonymous user.'; |
| 161 | |
| 162 | function testAnonLogout(){ |
| 163 | TestApp.fossil.logout({ |
| 164 | onResponse:function(resp,req){ |
| 165 | assertResponseOK(resp); |
| @@ -162,11 +176,11 @@ | |
| 176 | (function runAllTests(){ |
| 177 | var testList = [ |
| 178 | testHAI, |
| 179 | testIAmNobody, |
| 180 | testAnonymousLogin, |
| 181 | testAnonWiki, |
| 182 | testAnonLogout |
| 183 | ]; |
| 184 | var i, f; |
| 185 | for( i = 0; i < testList.length; ++i ){ |
| 186 | f = testList[i]; |
| 187 |