Fossil SCM
Added more integration tests.
Commit
10e677c968f668feedfd491fc1efd44815955c83
Parent
ef9d83931175327…
1 file changed
+38
-7
+38
-7
| --- ajax/i-test/rhino-test.js | ||
| +++ ajax/i-test/rhino-test.js | ||
| @@ -2,11 +2,12 @@ | ||
| 2 | 2 | serverUrl: |
| 3 | 3 | 'http://localhost:8080' |
| 4 | 4 | //'http://fjson/cgi-bin/fossil-json.cgi' |
| 5 | 5 | //'http://192.168.1.62:8080' |
| 6 | 6 | , |
| 7 | - verbose:true | |
| 7 | + verbose:true, | |
| 8 | + wiki:{} | |
| 8 | 9 | }; |
| 9 | 10 | (function bootstrap() { |
| 10 | 11 | var srcdir = '../js/'; |
| 11 | 12 | var includes = [srcdir+'json2.js', |
| 12 | 13 | srcdir+'whajaj.js', |
| @@ -19,17 +20,17 @@ | ||
| 19 | 20 | TestApp.fossil = new FossilAjaj({ |
| 20 | 21 | asynchronous:false, /* rhino-based impl doesn't support asynch. */ |
| 21 | 22 | url:TestApp.serverUrl, |
| 22 | 23 | beforeSend:function(req,opt){ |
| 23 | 24 | if(!TestApp.verbose) return; |
| 24 | - print("SENDING REQUEST: opt="+JSON.stringify(opt)); | |
| 25 | - if(req) print("Request="+WhAjaj.stringify(req)); | |
| 25 | + print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt)); | |
| 26 | + if(req) print("Request envelope="+WhAjaj.stringify(req)); | |
| 26 | 27 | }, |
| 27 | 28 | afterSend:function(req,opt){ |
| 28 | - if(!TestApp.verbose) return; | |
| 29 | - print("SENT REQUEST: opt="+JSON.stringify(opt)); | |
| 30 | - if(req) print("Request="+WhAjaj.stringify(req)); | |
| 29 | + //if(!TestApp.verbose) return; | |
| 30 | + //print("REQUEST RETURNED: opt="+JSON.stringify(opt)); | |
| 31 | + //if(req) print("Request="+WhAjaj.stringify(req)); | |
| 31 | 32 | }, |
| 32 | 33 | onError:function(req,opt){ |
| 33 | 34 | if(!TestApp.verbose) return; |
| 34 | 35 | print("ERROR: "+WhAjaj.stringify(opt)); |
| 35 | 36 | }, |
| @@ -120,17 +121,47 @@ | ||
| 120 | 121 | assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken); |
| 121 | 122 | assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName); |
| 122 | 123 | } |
| 123 | 124 | testAnonymousLogin.description = 'Perform anonymous login.'; |
| 124 | 125 | |
| 126 | +function testAnonWikiList(){ | |
| 127 | + TestApp.fossil.sendCommand('/json/wiki/list',undefined,{ | |
| 128 | + beforeSend:function(req,opt){ | |
| 129 | + TestApp.fossil.ajaj.options.beforeSend(req,opt); | |
| 130 | + assert( req && (req.authToken==TestApp.fossil.authToken) ); | |
| 131 | + }, | |
| 132 | + onResponse:function(resp,req){ | |
| 133 | + assertResponseOK(resp); | |
| 134 | + assert( (typeof [] === typeof resp.payload) && resp.payload.length, | |
| 135 | + "Wiki list seems to be okay."); | |
| 136 | + TestApp.wiki.list = resp.payload; | |
| 137 | + } | |
| 138 | + }); | |
| 139 | +} | |
| 140 | +testAnonWikiList.description = 'Fetch wiki list as anonymous uses.'; | |
| 125 | 141 | |
| 142 | +function testAnonLogout(){ | |
| 143 | + TestApp.fossil.logout({ | |
| 144 | + onResponse:function(resp,req){ | |
| 145 | + assertResponseOK(resp); | |
| 146 | + } | |
| 147 | + }); | |
| 148 | + TestApp.fossil.logout({ | |
| 149 | + onResponse:function(resp,req){ | |
| 150 | + assertResponseError(resp); | |
| 151 | + } | |
| 152 | + }); | |
| 153 | +} | |
| 154 | +testAnonLogout.description = 'Fetch wiki list as anonymous uses.'; | |
| 126 | 155 | |
| 127 | 156 | (function runAllTests(){ |
| 128 | 157 | var testList = [ |
| 129 | 158 | testHAI, |
| 130 | 159 | testIAmNobody, |
| 131 | - testAnonymousLogin | |
| 160 | + testAnonymousLogin, | |
| 161 | + testAnonWikiList, | |
| 162 | + testAnonLogout | |
| 132 | 163 | ]; |
| 133 | 164 | var i, f; |
| 134 | 165 | for( i = 0; i < testList.length; ++i ){ |
| 135 | 166 | f = testList[i]; |
| 136 | 167 | try{ |
| 137 | 168 |
| --- ajax/i-test/rhino-test.js | |
| +++ ajax/i-test/rhino-test.js | |
| @@ -2,11 +2,12 @@ | |
| 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 | }; |
| 9 | (function bootstrap() { |
| 10 | var srcdir = '../js/'; |
| 11 | var includes = [srcdir+'json2.js', |
| 12 | srcdir+'whajaj.js', |
| @@ -19,17 +20,17 @@ | |
| 19 | TestApp.fossil = new FossilAjaj({ |
| 20 | asynchronous:false, /* rhino-based impl doesn't support asynch. */ |
| 21 | url:TestApp.serverUrl, |
| 22 | beforeSend:function(req,opt){ |
| 23 | if(!TestApp.verbose) return; |
| 24 | print("SENDING REQUEST: opt="+JSON.stringify(opt)); |
| 25 | if(req) print("Request="+WhAjaj.stringify(req)); |
| 26 | }, |
| 27 | afterSend:function(req,opt){ |
| 28 | if(!TestApp.verbose) return; |
| 29 | print("SENT REQUEST: opt="+JSON.stringify(opt)); |
| 30 | if(req) print("Request="+WhAjaj.stringify(req)); |
| 31 | }, |
| 32 | onError:function(req,opt){ |
| 33 | if(!TestApp.verbose) return; |
| 34 | print("ERROR: "+WhAjaj.stringify(opt)); |
| 35 | }, |
| @@ -120,17 +121,47 @@ | |
| 120 | assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken); |
| 121 | assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName); |
| 122 | } |
| 123 | testAnonymousLogin.description = 'Perform anonymous login.'; |
| 124 | |
| 125 | |
| 126 | |
| 127 | (function runAllTests(){ |
| 128 | var testList = [ |
| 129 | testHAI, |
| 130 | testIAmNobody, |
| 131 | testAnonymousLogin |
| 132 | ]; |
| 133 | var i, f; |
| 134 | for( i = 0; i < testList.length; ++i ){ |
| 135 | f = testList[i]; |
| 136 | try{ |
| 137 |
| --- ajax/i-test/rhino-test.js | |
| +++ ajax/i-test/rhino-test.js | |
| @@ -2,11 +2,12 @@ | |
| 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() { |
| 11 | var srcdir = '../js/'; |
| 12 | var includes = [srcdir+'json2.js', |
| 13 | srcdir+'whajaj.js', |
| @@ -19,17 +20,17 @@ | |
| 20 | TestApp.fossil = new FossilAjaj({ |
| 21 | asynchronous:false, /* rhino-based impl doesn't support asynch. */ |
| 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)); |
| 27 | }, |
| 28 | afterSend:function(req,opt){ |
| 29 | //if(!TestApp.verbose) return; |
| 30 | //print("REQUEST RETURNED: opt="+JSON.stringify(opt)); |
| 31 | //if(req) print("Request="+WhAjaj.stringify(req)); |
| 32 | }, |
| 33 | onError:function(req,opt){ |
| 34 | if(!TestApp.verbose) return; |
| 35 | print("ERROR: "+WhAjaj.stringify(opt)); |
| 36 | }, |
| @@ -120,17 +121,47 @@ | |
| 121 | assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken); |
| 122 | assert( 'string' === typeof TestApp.fossil.userName, 'User name = '+TestApp.fossil.userName); |
| 123 | } |
| 124 | testAnonymousLogin.description = 'Perform anonymous login.'; |
| 125 | |
| 126 | function testAnonWikiList(){ |
| 127 | TestApp.fossil.sendCommand('/json/wiki/list',undefined,{ |
| 128 | beforeSend:function(req,opt){ |
| 129 | TestApp.fossil.ajaj.options.beforeSend(req,opt); |
| 130 | assert( req && (req.authToken==TestApp.fossil.authToken) ); |
| 131 | }, |
| 132 | onResponse:function(resp,req){ |
| 133 | assertResponseOK(resp); |
| 134 | assert( (typeof [] === typeof resp.payload) && resp.payload.length, |
| 135 | "Wiki list seems to be okay."); |
| 136 | TestApp.wiki.list = resp.payload; |
| 137 | } |
| 138 | }); |
| 139 | } |
| 140 | testAnonWikiList.description = 'Fetch wiki list as anonymous uses.'; |
| 141 | |
| 142 | function testAnonLogout(){ |
| 143 | TestApp.fossil.logout({ |
| 144 | onResponse:function(resp,req){ |
| 145 | assertResponseOK(resp); |
| 146 | } |
| 147 | }); |
| 148 | TestApp.fossil.logout({ |
| 149 | onResponse:function(resp,req){ |
| 150 | assertResponseError(resp); |
| 151 | } |
| 152 | }); |
| 153 | } |
| 154 | testAnonLogout.description = 'Fetch wiki list as anonymous uses.'; |
| 155 | |
| 156 | (function runAllTests(){ |
| 157 | var testList = [ |
| 158 | testHAI, |
| 159 | testIAmNobody, |
| 160 | testAnonymousLogin, |
| 161 | testAnonWikiList, |
| 162 | testAnonLogout |
| 163 | ]; |
| 164 | var i, f; |
| 165 | for( i = 0; i < testList.length; ++i ){ |
| 166 | f = testList[i]; |
| 167 | try{ |
| 168 |