Fossil SCM

added test for /json/wiki/get.

stephan 2011-10-01 05:05 UTC json
Commit 2b7edce38d7b11e55b9418117a648179e0958bd4
1 file changed +18 -4
--- ajax/i-test/rhino-test.js
+++ ajax/i-test/rhino-test.js
@@ -1,10 +1,11 @@
11
var TestApp = {
22
serverUrl:
3
- 'http://localhost:8080'
3
+ //'http://localhost:8080'
44
//'http://fjson/cgi-bin/fossil-json.cgi'
55
//'http://192.168.1.62:8080'
6
+ 'http://fossil.wanderinghorse.net/repos/fossil-json-java/index.cgi'
67
,
78
verbose:true,
89
wiki:{}
910
};
1011
(function bootstrap() {
@@ -17,10 +18,11 @@
1718
load(includes[i]);
1819
}
1920
WhAjaj.Connector.prototype.sendImpl = WhAjaj.Connector.sendImpls.rhino;
2021
TestApp.fossil = new FossilAjaj({
2122
asynchronous:false, /* rhino-based impl doesn't support async or timeout. */
23
+ timeout:0,
2224
url:TestApp.serverUrl,
2325
beforeSend:function(req,opt){
2426
if(!TestApp.verbose) return;
2527
print("SENDING REQUEST: AJAJ options="+JSON.stringify(opt));
2628
if(req) print("Request envelope="+WhAjaj.stringify(req));
@@ -124,14 +126,17 @@
124126
125127
function testAnonymousLogin(){
126128
TestApp.fossil.login();
127129
assert('string' === typeof TestApp.fossil.authToken, 'authToken = '+TestApp.fossil.authToken);
128130
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);
129134
}
130135
testAnonymousLogin.description = 'Perform anonymous login.';
131136
132
-function testAnonWikiList(){
137
+function testAnonWiki(){
133138
TestApp.fossil.sendCommand('/json/wiki/list',undefined,{
134139
beforeSend:function(req,opt){
135140
TestApp.fossil.ajaj.options.beforeSend(req,opt);
136141
assert( req && (req.authToken==TestApp.fossil.authToken), 'Request envelope contains expected authToken.' );
137142
},
@@ -140,12 +145,21 @@
140145
assert( (typeof [] === typeof resp.payload) && resp.payload.length,
141146
"Wiki list seems to be okay.");
142147
TestApp.wiki.list = resp.payload;
143148
}
144149
});
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
+ });
145159
}
146
-testAnonWikiList.description = 'Fetch wiki list as anonymous user.';
160
+testAnonWiki.description = 'Fetch wiki list as anonymous user.';
147161
148162
function testAnonLogout(){
149163
TestApp.fossil.logout({
150164
onResponse:function(resp,req){
151165
assertResponseOK(resp);
@@ -162,11 +176,11 @@
162176
(function runAllTests(){
163177
var testList = [
164178
testHAI,
165179
testIAmNobody,
166180
testAnonymousLogin,
167
- testAnonWikiList,
181
+ testAnonWiki,
168182
testAnonLogout
169183
];
170184
var i, f;
171185
for( i = 0; i < testList.length; ++i ){
172186
f = testList[i];
173187
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button