Fossil SCM

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.

rberteig 2016-01-30 00:43 rberteig-json-test
Commit f28e771369fe2e3eb97b9f92d83a201005ec0b83
1 file changed +32 -4
+32 -4
--- test/json.test
+++ test/json.test
@@ -69,10 +69,11 @@
6969
if {$status eq "200"} {
7070
set JR [::json::json2dict $body]
7171
}
7272
return $status
7373
}
74
+
7475
7576
# Inspect a dict for keys it must have and keys it must not have
7677
proc test_dict_keys {testname D okfields badfields} {
7778
set i 1
7879
foreach f $okfields {
@@ -277,11 +278,38 @@
277278
# payload depends on specific area and may be completely empty
278279
}
279280
280281
#### DIFFS
281282
# json diff v1 v2
282
-test TODO-json-diff false knownBug
283
+
284
+write_file fish {
285
+ABCD goldfish
286
+}
287
+fossil add fish
288
+fossil ci -m "goldfish"
289
+fossil_json finfo fish
290
+set fishHist [dict get $JR payload checkins]
291
+set fishV1 [dict get [lindex $fishHist 0] uuid]
292
+
293
+write_file fish {
294
+ABCD goldfish
295
+LMNO goldfish
296
+}
297
+fossil ci -m "goldfish"
298
+fossil_json finfo fish
299
+set fishHist [dict get $JR payload checkins]
300
+set fishV2 [dict get [lindex $fishHist 0] uuid]
301
+
302
+test fossil-diff-setup {$fishV1 ne $fishV2}
303
+fossil_json diff $fishV1 $fishV2
304
+test_json_envelope_ok json-diff-env
305
+test_json_payload json-diff {from to diff} {}
306
+test json-diff-v1 {[dict get $JR payload from] eq $fishV1}
307
+test json-diff-v2 {[dict get $JR payload to] eq $fishV2}
308
+set diff [dict get $JR payload diff]
309
+test json-diff-diff {[string first "+LMNO goldfish" $diff] >= 0}
310
+protOut [dict get $JR payload diff]
283311
284312
285313
#### DIRECTORY LISTING
286314
# json dir DIRNAME
287315
fossil_json dir
@@ -535,11 +563,13 @@
535563
# foreach c $codes {
536564
# puts [dict values $c]
537565
# }
538566
539567
540
-##### From the API Docs
568
+
569
+#### From the API Docs
570
+
541571
# Reminder to self: in March 2012 i saw a corner-case which returns
542572
# HTML output. To reproduce: chmod 444 REPO, then submit a request
543573
# which writes something (timeline creates a temp table). The "repo
544574
# is not writable" error comes back as HTML. i don't know if the
545575
# error happens before we have made the determination that the app is
@@ -558,10 +588,8 @@
558588
fossil_http_json /json/timeline/checkin $U1Cookie -expectError
559589
test json-ROrepo-2-1 {$CODE != 0}
560590
test json-ROrepo-2-2 {[regexp {\}\s*$} $RESULT]} knownBug
561591
test json-ROrepo-2-3 {![regexp {SQLITE_[A-Z]+:} $RESULT]} knownBug
562592
#test_json_envelope_ok json-http-timeline2
563
-
564
-
565593
catch {exec chmod 666 .rep.fossil}; # Unix. What about Win?
566594
567595
568596
--- test/json.test
+++ test/json.test
@@ -69,10 +69,11 @@
69 if {$status eq "200"} {
70 set JR [::json::json2dict $body]
71 }
72 return $status
73 }
 
74
75 # Inspect a dict for keys it must have and keys it must not have
76 proc test_dict_keys {testname D okfields badfields} {
77 set i 1
78 foreach f $okfields {
@@ -277,11 +278,38 @@
277 # payload depends on specific area and may be completely empty
278 }
279
280 #### DIFFS
281 # json diff v1 v2
282 test TODO-json-diff false knownBug
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
284
285 #### DIRECTORY LISTING
286 # json dir DIRNAME
287 fossil_json dir
@@ -535,11 +563,13 @@
535 # foreach c $codes {
536 # puts [dict values $c]
537 # }
538
539
540 ##### From the API Docs
 
 
541 # Reminder to self: in March 2012 i saw a corner-case which returns
542 # HTML output. To reproduce: chmod 444 REPO, then submit a request
543 # which writes something (timeline creates a temp table). The "repo
544 # is not writable" error comes back as HTML. i don't know if the
545 # error happens before we have made the determination that the app is
@@ -558,10 +588,8 @@
558 fossil_http_json /json/timeline/checkin $U1Cookie -expectError
559 test json-ROrepo-2-1 {$CODE != 0}
560 test json-ROrepo-2-2 {[regexp {\}\s*$} $RESULT]} knownBug
561 test json-ROrepo-2-3 {![regexp {SQLITE_[A-Z]+:} $RESULT]} knownBug
562 #test_json_envelope_ok json-http-timeline2
563
564
565 catch {exec chmod 666 .rep.fossil}; # Unix. What about Win?
566
567
568
--- test/json.test
+++ test/json.test
@@ -69,10 +69,11 @@
69 if {$status eq "200"} {
70 set JR [::json::json2dict $body]
71 }
72 return $status
73 }
74
75
76 # Inspect a dict for keys it must have and keys it must not have
77 proc test_dict_keys {testname D okfields badfields} {
78 set i 1
79 foreach f $okfields {
@@ -277,11 +278,38 @@
278 # payload depends on specific area and may be completely empty
279 }
280
281 #### DIFFS
282 # json diff v1 v2
283
284 write_file fish {
285 ABCD goldfish
286 }
287 fossil add fish
288 fossil ci -m "goldfish"
289 fossil_json finfo fish
290 set fishHist [dict get $JR payload checkins]
291 set fishV1 [dict get [lindex $fishHist 0] uuid]
292
293 write_file fish {
294 ABCD goldfish
295 LMNO goldfish
296 }
297 fossil ci -m "goldfish"
298 fossil_json finfo fish
299 set fishHist [dict get $JR payload checkins]
300 set fishV2 [dict get [lindex $fishHist 0] uuid]
301
302 test fossil-diff-setup {$fishV1 ne $fishV2}
303 fossil_json diff $fishV1 $fishV2
304 test_json_envelope_ok json-diff-env
305 test_json_payload json-diff {from to diff} {}
306 test json-diff-v1 {[dict get $JR payload from] eq $fishV1}
307 test json-diff-v2 {[dict get $JR payload to] eq $fishV2}
308 set diff [dict get $JR payload diff]
309 test json-diff-diff {[string first "+LMNO goldfish" $diff] >= 0}
310 protOut [dict get $JR payload diff]
311
312
313 #### DIRECTORY LISTING
314 # json dir DIRNAME
315 fossil_json dir
@@ -535,11 +563,13 @@
563 # foreach c $codes {
564 # puts [dict values $c]
565 # }
566
567
568
569 #### From the API Docs
570
571 # Reminder to self: in March 2012 i saw a corner-case which returns
572 # HTML output. To reproduce: chmod 444 REPO, then submit a request
573 # which writes something (timeline creates a temp table). The "repo
574 # is not writable" error comes back as HTML. i don't know if the
575 # error happens before we have made the determination that the app is
@@ -558,10 +588,8 @@
588 fossil_http_json /json/timeline/checkin $U1Cookie -expectError
589 test json-ROrepo-2-1 {$CODE != 0}
590 test json-ROrepo-2-2 {[regexp {\}\s*$} $RESULT]} knownBug
591 test json-ROrepo-2-3 {![regexp {SQLITE_[A-Z]+:} $RESULT]} knownBug
592 #test_json_envelope_ok json-http-timeline2
 
 
593 catch {exec chmod 666 .rep.fossil}; # Unix. What about Win?
594
595
596

Keyboard Shortcuts

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