Fossil

Check-in [f28e7713]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added test case for /json/diff/UUID_V1/UUID_V2. Note that this case passes and clearly does diff the versions in the expected order.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | rberteig-json-test
Files: files | file ages | folders
SHA1: f28e771369fe2e3eb97b9f92d83a201005ec0b83
User & Date: rberteig 2016-01-30 00:43:48
Context
2016-01-30
01:30
Add support for POST in JSON over HTTP. Test /json/cap with various ways of delivering an authToken to cover the rest of the Authentication category basic functionality. NOTE that supplying the authToken in the POSTed JSON request envelope does not appear to work. Passing it in a cookie or in a GET parameter does work as expected. check-in: 479aadb1 user: rberteig tags: rberteig-json-test
00:43
Added test case for /json/diff/UUID_V1/UUID_V2. Note that this case passes and clearly does diff the versions in the expected order. check-in: f28e7713 user: rberteig tags: rberteig-json-test
2016-01-29
23:46
Add test case for issue with a read-only fossil repository causing confusing results for the JSON API over HTTP. check-in: dc042c6a user: rberteig tags: rberteig-json-test
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/json.test.

67
68
69
70
71
72
73

74
75
76
77
78
79
80
...
275
276
277
278
279
280
281
282




























283
284
285
286
287
288
289
...
533
534
535
536
537
538
539

540

541
542
543
544
545
546
547
...
556
557
558
559
560
561
562
563
564
565
566
567
  regexp {(?w)(.*)^\s*$(.*)} $RESULT dummy head body
  regexp {^HTTP\S+\s+(\d\d\d)\s+(.*)$} $head dummy status msg
  if {$status eq "200"} {
    set JR [::json::json2dict $body]
  }
  return $status
}


# Inspect a dict for keys it must have and keys it must not have
proc test_dict_keys {testname D okfields badfields} {
  set i 1
  foreach f $okfields {
    test "$testname-$i" {[dict exists $D $f]}
    incr i
................................................................................
  fossil_json config get $a 
  test_json_envelope_ok json-config-$a-env
  # payload depends on specific area and may be completely empty
}

#### DIFFS
# json diff v1 v2
test TODO-json-diff false knownBug






























#### DIRECTORY LISTING
# json dir DIRNAME
fossil_json dir 
test_json_envelope_ok json-dir-env
test_json_payload json-dir {name entries} {}
................................................................................
set codes [dict get $JR payload]
test json-resultCodes-codes-1 {[llength $codes] >= 35} ;# count as of API 20120713
# foreach c $codes {
#   puts [dict values $c]
# }



##### From the API Docs

# Reminder to self: in March 2012 i saw a corner-case which returns
# HTML output. To reproduce: chmod 444 REPO, then submit a request
# which writes something (timeline creates a temp table). The "repo
# is not writable" error comes back as HTML. i don't know if the
# error happens before we have made the determination that the app is
# in JSON mode or if the error handling is incorrectly not
# recognizing JSON mode. 
................................................................................
protOut "chmod 444 repo"
catch {exec chmod 444 .rep.fossil}; # Unix. What about Win?
fossil_http_json /json/timeline/checkin $U1Cookie -expectError
test json-ROrepo-2-1 {$CODE != 0}
test json-ROrepo-2-2 {[regexp {\}\s*$} $RESULT]} knownBug
test json-ROrepo-2-3 {![regexp {SQLITE_[A-Z]+:} $RESULT]} knownBug
#test_json_envelope_ok json-http-timeline2


catch {exec chmod 666 .rep.fossil}; # Unix. What about Win?









>







 







<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
|
>







 







<
<



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
...
276
277
278
279
280
281
282

283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
...
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
...
586
587
588
589
590
591
592


593
594
595
  regexp {(?w)(.*)^\s*$(.*)} $RESULT dummy head body
  regexp {^HTTP\S+\s+(\d\d\d)\s+(.*)$} $head dummy status msg
  if {$status eq "200"} {
    set JR [::json::json2dict $body]
  }
  return $status
}


# Inspect a dict for keys it must have and keys it must not have
proc test_dict_keys {testname D okfields badfields} {
  set i 1
  foreach f $okfields {
    test "$testname-$i" {[dict exists $D $f]}
    incr i
................................................................................
  fossil_json config get $a 
  test_json_envelope_ok json-config-$a-env
  # payload depends on specific area and may be completely empty
}

#### DIFFS
# json diff v1 v2


write_file fish {
ABCD goldfish
}
fossil add fish
fossil ci -m "goldfish"
fossil_json finfo fish
set fishHist [dict get $JR payload checkins]
set fishV1 [dict get [lindex $fishHist 0] uuid]

write_file fish {
ABCD goldfish
LMNO goldfish
}
fossil ci -m "goldfish"
fossil_json finfo fish
set fishHist [dict get $JR payload checkins]
set fishV2 [dict get [lindex $fishHist 0] uuid]

test fossil-diff-setup {$fishV1 ne $fishV2}
fossil_json diff $fishV1 $fishV2
test_json_envelope_ok json-diff-env
test_json_payload json-diff {from to diff} {}
test json-diff-v1 {[dict get $JR payload from] eq $fishV1}
test json-diff-v2 {[dict get $JR payload to] eq $fishV2}
set diff [dict get $JR payload diff]
test json-diff-diff {[string first "+LMNO goldfish" $diff] >= 0}
protOut [dict get $JR payload diff]


#### DIRECTORY LISTING
# json dir DIRNAME
fossil_json dir 
test_json_envelope_ok json-dir-env
test_json_payload json-dir {name entries} {}
................................................................................
set codes [dict get $JR payload]
test json-resultCodes-codes-1 {[llength $codes] >= 35} ;# count as of API 20120713
# foreach c $codes {
#   puts [dict values $c]
# }



#### From the API Docs

# Reminder to self: in March 2012 i saw a corner-case which returns
# HTML output. To reproduce: chmod 444 REPO, then submit a request
# which writes something (timeline creates a temp table). The "repo
# is not writable" error comes back as HTML. i don't know if the
# error happens before we have made the determination that the app is
# in JSON mode or if the error handling is incorrectly not
# recognizing JSON mode. 
................................................................................
protOut "chmod 444 repo"
catch {exec chmod 444 .rep.fossil}; # Unix. What about Win?
fossil_http_json /json/timeline/checkin $U1Cookie -expectError
test json-ROrepo-2-1 {$CODE != 0}
test json-ROrepo-2-2 {[regexp {\}\s*$} $RESULT]} knownBug
test json-ROrepo-2-3 {![regexp {SQLITE_[A-Z]+:} $RESULT]} knownBug
#test_json_envelope_ok json-http-timeline2


catch {exec chmod 666 .rep.fossil}; # Unix. What about Win?