Fossil SCM

Added more coverage of /json, leaving /json/login, /json/diff, and /json/user/save uncovered, and finding surprises with /json/wiki/diff, /json/timeline/ci, and /json/tag/cancel. All implemented coverage is of the best documented and easiest tested paths through each feature. Tests for edge cases and failure paths are not yet in place, nor are complete tests for full expected values in most cases.

rberteig 2016-01-29 02:37 rberteig-json-test
Commit c2c49b3543e9bd02a507a2e19d57dbc006d44264
1 file changed +157 -2
+157 -2
--- test/json.test
+++ test/json.test
@@ -158,11 +158,11 @@
158158
test_json_envelope_ok json-artifact-file-env
159159
test json-artifact-file {[dict get $JR payload type] eq "file"}
160160
test_json_payload json-artifact [concat type uuid size checkins] {}
161161
162162
# json artifact (wiki)
163
-fossil wiki create Empty empty
163
+fossil wiki create Empty <<"-=BLANK=-"
164164
fossil_json wiki get Empty
165165
test json-wiki-get {[dict get $JR payload name] eq "Empty"}
166166
set uuid [dict get $JR payload uuid]
167167
fossil_json artifact $uuid
168168
test_json_envelope_ok json-artifact-wiki-env
@@ -234,11 +234,11 @@
234234
test_json_envelope_ok json-cap-env
235235
# No point checking any other flags, setup implies all, and all are
236236
# moot from CLI.
237237
test json-cap-CLI {[dict get $JR payload permissionFlags setup]}
238238
239
-test TODO-JSON-POST-AUTHENTICATION false knownBug
239
+test TODO-json-post-authentication false knownBug
240240
#TODO: implement support for POST with JSON payload from file
241241
#fossil_http_post_json /json anon-2
242242
#test_json_envelope_ok json-cap-http-env
243243
#test json-cap-http {![dict get $JR payload permissionFlags setup]}
244244
@@ -249,29 +249,184 @@
249249
test_json_payload json-whoami-cli {name capabilities} {}
250250
test json-whoami-cli-name {[dict get $JR payload name] eq "nobody"}
251251
test_hascaps json-whoami-cli-cap "gjorz" [dict get $JR payload capabilities]
252252
253253
#### BRANCHES
254
+# json branch list
254255
fossil_json branch list
255256
test_json_envelope_ok json-branch-list-env
256257
test_json_payload json-branch-list {range current branches} {}
258
+test json-branch-list-cur {[dict get $JR payload current] eq "trunk"}
259
+test json-branch-list-cnt {[llength [dict get $JR payload branches]] == 1}
260
+test json-branch-list-val {[dict get $JR payload branches] eq "trunk"}
257261
262
+# json branch create
263
+fossil_json branch create alpha --basis trunk
264
+test_json_envelope_ok json-branch-create-env
265
+test_json_payload json-branch-create {name basis rid uuid isPrivate} {}
258266
259267
260268
#### CONFIG
269
+# json config get AREA
270
+# AREAs are skin ticket project all skin-backup
271
+foreach a [list skin ticket project all skin-backup] {
272
+ fossil_json config get $a
273
+ test_json_envelope_ok json-config-$a-env
274
+ # payload depends on specific area and may be completely empty
275
+}
276
+
261277
#### DIFFS
278
+# json diff v1 v2
279
+test TODO-json-diff false knownBug
280
+
281
+
262282
#### DIRECTORY LISTING
283
+# json dir DIRNAME
284
+fossil_json dir
285
+test_json_envelope_ok json-dir-env
286
+test_json_payload json-dir {name entries} {}
287
+
263288
#### FILE INFO
289
+# json finfo FILENAME
290
+fossil_json finfo empty
291
+test_json_envelope_ok json-finfo-env
292
+test_json_payload json-finfo {name checkins} {}
293
+
264294
#### QUERY
295
+# json query SQLCODE
296
+fossil_json query {"SELECT * FROM reportfmt"}
297
+test_json_envelope_ok json-query-env
298
+test_json_payload json-query {columns rows} {}
299
+
265300
#### STATS
301
+# json stat
302
+fossil_json stat
303
+test_json_envelope_ok json-stat-env
304
+test_json_payload json-stat {repositorySize ageDays ageYears projectCode compiler sqlite} \
305
+{blobCount deltaCount uncompressedArtifactSize averageArtifactSize maxArtifactSize \
306
+compressionRatio checkinCount fileCount wikiPageCount ticketCount}
307
+
308
+fossil_json stat -f
309
+test_json_envelope_ok json-stat-env
310
+test_json_payload json-stat {repositorySize \
311
+blobCount deltaCount uncompressedArtifactSize averageArtifactSize maxArtifactSize \
312
+compressionRatio checkinCount fileCount wikiPageCount ticketCount \
313
+ageDays ageYears projectCode compiler sqlite} {}
314
+
315
+
266316
#### STATUS
317
+# NOTE: Local checkout required
318
+# json status
319
+fossil_json status
320
+test_json_envelope_ok json-status-env
321
+test_json_payload json-status {repository localRoot checkout files errorCount} {}
322
+
267323
#### TAGS
324
+
325
+# json tag add NAME CHECKIN VALUE
326
+fossil_json tag add blue trunk green
327
+test_json_envelope_ok json-tag-add-env
328
+test_json_payload json-tag-add {name value propagate raw appliedTo} {}
329
+
330
+
331
+# json tag cancel NAME CHECKIN
332
+fossil_json tag add cancel alpha
333
+test_json_envelope_ok json-tag-cancel-env
334
+# BUG? Doc says no payload.
335
+test_json_payload json-tag-cancel {name value propagate raw appliedTo} {}
336
+
337
+# json tag find NAME
338
+fossil_json tag find alpha
339
+test_json_envelope_ok json-tag-find-env
340
+test_json_payload json-tag-find {name raw type limit artifacts} {}
341
+test json-tag-find-count {[llength [dict get $JR payload artifacts]] >= 1}
342
+
343
+# json tag list CHECKIN
344
+fossil_json tag list
345
+test_json_envelope_ok json-tag-list-env
346
+test_json_payload json-tag-list {raw includeTickets tags} {}
347
+test json-tag-list-count {[llength [dict get $JR payload tags]] >= 2}
348
+
349
+
268350
#### TICKETS
351
+# API Docs say not yet defined, so it isn't quite fair to mark this
352
+# category as TODO for the test cases...
353
+# test TODO-json-tickets false knownBug
354
+
269355
#### TICKET REPORTS
356
+
357
+# json report get NUMBER
358
+fossil_json report get 1
359
+test_json_envelope_ok json-report-get-env
360
+test_json_payload json-report-get {report owner title timestamp columns sqlCode} {}
361
+
362
+# json report list
363
+fossil_json report list
364
+test_json_envelope_ok json-report-list-env
365
+#test_json_payload json-report-list {raw includeTickets tags} {}
366
+test json-report-list-count {[llength [dict get $JR payload]] >= 1}
367
+
368
+
369
+# json report run NUMBER
370
+fossil_json report run 1
371
+test_json_envelope_ok json-report-run-1-env
372
+test_json_payload json-report-list {report title sqlcode columnNames tickets} {}
373
+test json-report-list-count {[llength [dict get $JR payload columnNames]] >= 7}
374
+test json-report-list-count {[llength [dict get $JR payload tickets]] >= 0}
375
+
376
+
270377
#### TIMELINE
378
+
379
+# json timeline checkin
380
+fossil_json timeline checkin
381
+test_json_envelope_ok json-timeline-checkin-env
382
+test_json_payload json-timeline-checkin {limit timeline} {}
383
+set i 0
384
+foreach t [dict get $JR payload timeline] {
385
+ # parents appears only for entries that have a parent
386
+ # files appears only if requested by the --files parameter
387
+ test_dict_keys json-timeline-checkin-$i $t {type uuid timestamp comment user isLeaf tags} {}
388
+ incr i
389
+}
390
+
391
+# json timeline ci
392
+fossil_json timeline ci
393
+test json-timeline-ci {[dict get $JR resultCode] ne "FOSSIL-1102"} knownBug
394
+#test_json_payload json-timeline-ci {limit timeline} {}
395
+
396
+# json timeline ticket
397
+fossil_json timeline ticket
398
+test_json_envelope_ok json-timeline-ticket-env
399
+test_json_payload json-timeline-ticket {limit timeline} {}
400
+
401
+# json timeline wiki
402
+fossil_json timeline wiki
403
+test_json_envelope_ok json-timeline-wiki-env
404
+test_json_payload json-timeline-wiki {limit timeline} {}
405
+
406
+
271407
#### USER MANAGEMENT
272408
409
+# json user get
410
+foreach u [list nobody anonymous reader developer U1] {
411
+ fossil_json user get $u
412
+ test_json_envelope_ok json-user-get-$u-env
413
+ test_json_payload json-user-get-$u {uid name capabilities info timestamp} {}
414
+}
415
+
416
+# json user list
417
+fossil_json user list
418
+test_json_envelope_ok json-user-list-env
419
+set i 0
420
+foreach u [dict get $JR payload] {
421
+ test_dict_keys json-user-list-$i $u {uid name capabilities info timestamp} {}
422
+ incr i
423
+}
424
+
425
+# json user save
426
+test TODO-json-user-save false knownBug
427
+
273428
#### WIKI
274429
275430
# wiki list
276431
fossil_json wiki list
277432
test_json_envelope_ok json-wiki-list-env
278433
--- test/json.test
+++ test/json.test
@@ -158,11 +158,11 @@
158 test_json_envelope_ok json-artifact-file-env
159 test json-artifact-file {[dict get $JR payload type] eq "file"}
160 test_json_payload json-artifact [concat type uuid size checkins] {}
161
162 # json artifact (wiki)
163 fossil wiki create Empty empty
164 fossil_json wiki get Empty
165 test json-wiki-get {[dict get $JR payload name] eq "Empty"}
166 set uuid [dict get $JR payload uuid]
167 fossil_json artifact $uuid
168 test_json_envelope_ok json-artifact-wiki-env
@@ -234,11 +234,11 @@
234 test_json_envelope_ok json-cap-env
235 # No point checking any other flags, setup implies all, and all are
236 # moot from CLI.
237 test json-cap-CLI {[dict get $JR payload permissionFlags setup]}
238
239 test TODO-JSON-POST-AUTHENTICATION false knownBug
240 #TODO: implement support for POST with JSON payload from file
241 #fossil_http_post_json /json anon-2
242 #test_json_envelope_ok json-cap-http-env
243 #test json-cap-http {![dict get $JR payload permissionFlags setup]}
244
@@ -249,29 +249,184 @@
249 test_json_payload json-whoami-cli {name capabilities} {}
250 test json-whoami-cli-name {[dict get $JR payload name] eq "nobody"}
251 test_hascaps json-whoami-cli-cap "gjorz" [dict get $JR payload capabilities]
252
253 #### BRANCHES
 
254 fossil_json branch list
255 test_json_envelope_ok json-branch-list-env
256 test_json_payload json-branch-list {range current branches} {}
 
 
 
257
 
 
 
 
258
259
260 #### CONFIG
 
 
 
 
 
 
 
 
261 #### DIFFS
 
 
 
 
262 #### DIRECTORY LISTING
 
 
 
 
 
263 #### FILE INFO
 
 
 
 
 
264 #### QUERY
 
 
 
 
 
265 #### STATS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266 #### STATUS
 
 
 
 
 
 
267 #### TAGS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268 #### TICKETS
 
 
 
 
269 #### TICKET REPORTS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270 #### TIMELINE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271 #### USER MANAGEMENT
272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273 #### WIKI
274
275 # wiki list
276 fossil_json wiki list
277 test_json_envelope_ok json-wiki-list-env
278
--- test/json.test
+++ test/json.test
@@ -158,11 +158,11 @@
158 test_json_envelope_ok json-artifact-file-env
159 test json-artifact-file {[dict get $JR payload type] eq "file"}
160 test_json_payload json-artifact [concat type uuid size checkins] {}
161
162 # json artifact (wiki)
163 fossil wiki create Empty <<"-=BLANK=-"
164 fossil_json wiki get Empty
165 test json-wiki-get {[dict get $JR payload name] eq "Empty"}
166 set uuid [dict get $JR payload uuid]
167 fossil_json artifact $uuid
168 test_json_envelope_ok json-artifact-wiki-env
@@ -234,11 +234,11 @@
234 test_json_envelope_ok json-cap-env
235 # No point checking any other flags, setup implies all, and all are
236 # moot from CLI.
237 test json-cap-CLI {[dict get $JR payload permissionFlags setup]}
238
239 test TODO-json-post-authentication false knownBug
240 #TODO: implement support for POST with JSON payload from file
241 #fossil_http_post_json /json anon-2
242 #test_json_envelope_ok json-cap-http-env
243 #test json-cap-http {![dict get $JR payload permissionFlags setup]}
244
@@ -249,29 +249,184 @@
249 test_json_payload json-whoami-cli {name capabilities} {}
250 test json-whoami-cli-name {[dict get $JR payload name] eq "nobody"}
251 test_hascaps json-whoami-cli-cap "gjorz" [dict get $JR payload capabilities]
252
253 #### BRANCHES
254 # json branch list
255 fossil_json branch list
256 test_json_envelope_ok json-branch-list-env
257 test_json_payload json-branch-list {range current branches} {}
258 test json-branch-list-cur {[dict get $JR payload current] eq "trunk"}
259 test json-branch-list-cnt {[llength [dict get $JR payload branches]] == 1}
260 test json-branch-list-val {[dict get $JR payload branches] eq "trunk"}
261
262 # json branch create
263 fossil_json branch create alpha --basis trunk
264 test_json_envelope_ok json-branch-create-env
265 test_json_payload json-branch-create {name basis rid uuid isPrivate} {}
266
267
268 #### CONFIG
269 # json config get AREA
270 # AREAs are skin ticket project all skin-backup
271 foreach a [list skin ticket project all skin-backup] {
272 fossil_json config get $a
273 test_json_envelope_ok json-config-$a-env
274 # payload depends on specific area and may be completely empty
275 }
276
277 #### DIFFS
278 # json diff v1 v2
279 test TODO-json-diff false knownBug
280
281
282 #### DIRECTORY LISTING
283 # json dir DIRNAME
284 fossil_json dir
285 test_json_envelope_ok json-dir-env
286 test_json_payload json-dir {name entries} {}
287
288 #### FILE INFO
289 # json finfo FILENAME
290 fossil_json finfo empty
291 test_json_envelope_ok json-finfo-env
292 test_json_payload json-finfo {name checkins} {}
293
294 #### QUERY
295 # json query SQLCODE
296 fossil_json query {"SELECT * FROM reportfmt"}
297 test_json_envelope_ok json-query-env
298 test_json_payload json-query {columns rows} {}
299
300 #### STATS
301 # json stat
302 fossil_json stat
303 test_json_envelope_ok json-stat-env
304 test_json_payload json-stat {repositorySize ageDays ageYears projectCode compiler sqlite} \
305 {blobCount deltaCount uncompressedArtifactSize averageArtifactSize maxArtifactSize \
306 compressionRatio checkinCount fileCount wikiPageCount ticketCount}
307
308 fossil_json stat -f
309 test_json_envelope_ok json-stat-env
310 test_json_payload json-stat {repositorySize \
311 blobCount deltaCount uncompressedArtifactSize averageArtifactSize maxArtifactSize \
312 compressionRatio checkinCount fileCount wikiPageCount ticketCount \
313 ageDays ageYears projectCode compiler sqlite} {}
314
315
316 #### STATUS
317 # NOTE: Local checkout required
318 # json status
319 fossil_json status
320 test_json_envelope_ok json-status-env
321 test_json_payload json-status {repository localRoot checkout files errorCount} {}
322
323 #### TAGS
324
325 # json tag add NAME CHECKIN VALUE
326 fossil_json tag add blue trunk green
327 test_json_envelope_ok json-tag-add-env
328 test_json_payload json-tag-add {name value propagate raw appliedTo} {}
329
330
331 # json tag cancel NAME CHECKIN
332 fossil_json tag add cancel alpha
333 test_json_envelope_ok json-tag-cancel-env
334 # BUG? Doc says no payload.
335 test_json_payload json-tag-cancel {name value propagate raw appliedTo} {}
336
337 # json tag find NAME
338 fossil_json tag find alpha
339 test_json_envelope_ok json-tag-find-env
340 test_json_payload json-tag-find {name raw type limit artifacts} {}
341 test json-tag-find-count {[llength [dict get $JR payload artifacts]] >= 1}
342
343 # json tag list CHECKIN
344 fossil_json tag list
345 test_json_envelope_ok json-tag-list-env
346 test_json_payload json-tag-list {raw includeTickets tags} {}
347 test json-tag-list-count {[llength [dict get $JR payload tags]] >= 2}
348
349
350 #### TICKETS
351 # API Docs say not yet defined, so it isn't quite fair to mark this
352 # category as TODO for the test cases...
353 # test TODO-json-tickets false knownBug
354
355 #### TICKET REPORTS
356
357 # json report get NUMBER
358 fossil_json report get 1
359 test_json_envelope_ok json-report-get-env
360 test_json_payload json-report-get {report owner title timestamp columns sqlCode} {}
361
362 # json report list
363 fossil_json report list
364 test_json_envelope_ok json-report-list-env
365 #test_json_payload json-report-list {raw includeTickets tags} {}
366 test json-report-list-count {[llength [dict get $JR payload]] >= 1}
367
368
369 # json report run NUMBER
370 fossil_json report run 1
371 test_json_envelope_ok json-report-run-1-env
372 test_json_payload json-report-list {report title sqlcode columnNames tickets} {}
373 test json-report-list-count {[llength [dict get $JR payload columnNames]] >= 7}
374 test json-report-list-count {[llength [dict get $JR payload tickets]] >= 0}
375
376
377 #### TIMELINE
378
379 # json timeline checkin
380 fossil_json timeline checkin
381 test_json_envelope_ok json-timeline-checkin-env
382 test_json_payload json-timeline-checkin {limit timeline} {}
383 set i 0
384 foreach t [dict get $JR payload timeline] {
385 # parents appears only for entries that have a parent
386 # files appears only if requested by the --files parameter
387 test_dict_keys json-timeline-checkin-$i $t {type uuid timestamp comment user isLeaf tags} {}
388 incr i
389 }
390
391 # json timeline ci
392 fossil_json timeline ci
393 test json-timeline-ci {[dict get $JR resultCode] ne "FOSSIL-1102"} knownBug
394 #test_json_payload json-timeline-ci {limit timeline} {}
395
396 # json timeline ticket
397 fossil_json timeline ticket
398 test_json_envelope_ok json-timeline-ticket-env
399 test_json_payload json-timeline-ticket {limit timeline} {}
400
401 # json timeline wiki
402 fossil_json timeline wiki
403 test_json_envelope_ok json-timeline-wiki-env
404 test_json_payload json-timeline-wiki {limit timeline} {}
405
406
407 #### USER MANAGEMENT
408
409 # json user get
410 foreach u [list nobody anonymous reader developer U1] {
411 fossil_json user get $u
412 test_json_envelope_ok json-user-get-$u-env
413 test_json_payload json-user-get-$u {uid name capabilities info timestamp} {}
414 }
415
416 # json user list
417 fossil_json user list
418 test_json_envelope_ok json-user-list-env
419 set i 0
420 foreach u [dict get $JR payload] {
421 test_dict_keys json-user-list-$i $u {uid name capabilities info timestamp} {}
422 incr i
423 }
424
425 # json user save
426 test TODO-json-user-save false knownBug
427
428 #### WIKI
429
430 # wiki list
431 fossil_json wiki list
432 test_json_envelope_ok json-wiki-list-env
433

Keyboard Shortcuts

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