| | @@ -78,28 +78,41 @@ |
| 78 | 78 | write_file f3 "A technote" |
| 79 | 79 | fossil wiki create technote f3 --technote {2016-01-01 12:34} |
| 80 | 80 | test wiki-9 {$CODE == 0} |
| 81 | 81 | fossil wiki list --technote |
| 82 | 82 | test wiki-10 {[normalize_result] eq {2016-01-01 12:34:00}} |
| 83 | +fossil wiki list --technote --show-technote-ids |
| 84 | +set technotelist [split $RESULT "\n"] |
| 85 | +set veryfirsttechnoteid [lindex [split [lindex $technotelist 0]] 0] |
| 83 | 86 | |
| 84 | 87 | ############################################################################### |
| 85 | 88 | # exporting that technote should give back similar text |
| 86 | 89 | fossil wiki export a3 --technote {2016-01-01 12:34:00} |
| 87 | 90 | test wiki-11 {[similar_file f3 a3]} |
| 88 | 91 | |
| 89 | 92 | ############################################################################### |
| 90 | | -# Trying to add a technote with the same timestamp should fail |
| 91 | | -fossil wiki create 2ndnote f3 -technote {2016-01-01 12:34} -expectError |
| 92 | | -test wiki-13 {$CODE != 0} |
| 93 | +# Trying to add a technote with the same timestamp should succeed and create a |
| 94 | +# second tech note |
| 95 | +fossil wiki create 2ndnote f3 -technote {2016-01-01 12:34} |
| 96 | +test wiki-13 {$CODE == 0} |
| 97 | +fossil wiki list --technote |
| 98 | +set technotelist [split $RESULT "\n"] |
| 99 | +test wiki-13.1 {[llength $technotelist] == 2} |
| 93 | 100 | |
| 94 | 101 | ############################################################################### |
| 95 | 102 | # commiting a change to an existing technote should replace the page on export |
| 103 | +# (this should update the tech note from wiki-13 as that the most recently |
| 104 | +# updated one, that should also be the one exported by the export command) |
| 96 | 105 | write_file f4 "technote 2nd variant" |
| 97 | 106 | fossil wiki commit technote f4 --technote {2016-01-01 12:34} |
| 98 | 107 | test wiki-14 {$CODE == 0} |
| 99 | 108 | fossil wiki export a4 --technote {2016-01-01 12:34} |
| 100 | 109 | test wiki-15 {[similar_file f4 a4]} |
| 110 | +# Also check that the tech note with the same timestamp, but modified less |
| 111 | +# recently still has its original text |
| 112 | +fossil wiki export a4.1 --technote $veryfirsttechnoteid |
| 113 | +test wiki-15.1 {[similar_file f3 a4.1]} |
| 101 | 114 | |
| 102 | 115 | ############################################################################### |
| 103 | 116 | # But we shouldn't be able to update non-existant pages |
| 104 | 117 | fossil wiki commit doesntexist f1 -expectError |
| 105 | 118 | test wiki-16 {$CODE != 0} |
| | @@ -129,11 +142,11 @@ |
| 129 | 142 | test wiki-21 {$CODE != 0} |
| 130 | 143 | fossil attachment add tcltest fa |
| 131 | 144 | test wiki-22 {$CODE == 0} |
| 132 | 145 | |
| 133 | 146 | ############################################################################### |
| 134 | | -# Test adding an attachment to borg a non-existant (should fail) and existing tech note |
| 147 | +# Test adding an attachment to both a non-existant (should fail) and existing tech note |
| 135 | 148 | fossil attachment add fa --technote {2016-07-22 12:00} -expectError |
| 136 | 149 | test wiki-23 {$CODE != 0} |
| 137 | 150 | fossil attachment add fa --technote {2016-01-03 12:34} |
| 138 | 151 | test wiki-24 {$CODE == 0} |
| 139 | 152 | |
| | @@ -162,15 +175,14 @@ |
| 162 | 175 | write_file f8 "Contents of a 'unique' tech note" |
| 163 | 176 | fossil wiki create {Unique technote} f8 --technote {2016-01-05 01:02:03} |
| 164 | 177 | fossil timeline |
| 165 | 178 | test wiki-30 {[string match *Unique*technote* $RESULT]} |
| 166 | 179 | |
| 167 | | - |
| 168 | 180 | ############################################################################### |
| 169 | | -# Check for a collision between an attachment and a note, this is a |
| 170 | | -# bug that results from some code apparently treating the attachment |
| 171 | | -# entry as if it were a technote when it isn't really. |
| 181 | +# Check for a collision between an attachment and a note, this was a |
| 182 | +# bug that resulted from some code treating the attachment entry as if it |
| 183 | +# were a technote when it isn't really. |
| 172 | 184 | # |
| 173 | 185 | # First, wait for the top of the next second so the attachment |
| 174 | 186 | # happens at a known time, then add an attachment to an existing note |
| 175 | 187 | # and a new note immediately after. |
| 176 | 188 | |
| | @@ -214,22 +226,22 @@ |
| 214 | 226 | fossil wiki list -t |
| 215 | 227 | test wiki-36-2 {$CODE == 0} |
| 216 | 228 | |
| 217 | 229 | ############################################################################### |
| 218 | 230 | # Check that we have the expected number of tech notes on the list (and not |
| 219 | | -# extra ones from other events (such as the attachments) - 7 tech notes |
| 220 | | -# expected created by tests 9, 17, 19, 29, 31, 32 and 34 |
| 231 | +# extra ones from other events (such as the attachments) - 8 tech notes |
| 232 | +# expected created by tests 9, 13, 17, 19, 29, 31, 32 and 34 |
| 221 | 233 | fossil wiki list --technote |
| 222 | 234 | set technotelist [split $RESULT "\n"] |
| 223 | | -test wiki-37 {[llength $technotelist] == 7} |
| 235 | +test wiki-37 {[llength $technotelist] == 8} |
| 224 | 236 | |
| 225 | 237 | ############################################################################### |
| 226 | 238 | # Check that using the show-technote-ids shows the same tech notes in the same |
| 227 | | -# order (with the technote id as the first word of the line |
| 239 | +# order (with the technote id as the first word of the line) |
| 228 | 240 | fossil wiki list --technote --show-technote-ids |
| 229 | 241 | set technoteidlist [split $RESULT "\n"] |
| 230 | | -test wiki-38 {[llength $technotelist] == 7} |
| 242 | +test wiki-38 {[llength $technotelist] == 8} |
| 231 | 243 | for {set i 0} {$i < [llength $technotelist]} {incr i} { |
| 232 | 244 | set match "???????????????????????????????????????? " |
| 233 | 245 | append match [lindex $technotelist $i] |
| 234 | 246 | test "wiki-39-$i" {[string match $match [lindex $technoteidlist $i]]} |
| 235 | 247 | } |
| | @@ -239,20 +251,20 @@ |
| 239 | 251 | # the contents of the oldest tech note (by tech note id, both full and short) match up |
| 240 | 252 | write_file f12 "A really old tech note" |
| 241 | 253 | fossil wiki create {Old tech note} f12 --technote {2001-07-07 09:08:07} |
| 242 | 254 | fossil wiki list --technote --show-technote-ids |
| 243 | 255 | set technotelist [split $RESULT "\n"] |
| 244 | | -set oldesttechnoteid [lindex [split [lindex $technotelist [llength $technotelist]-1]] 0] |
| 245 | | -fossil wiki export a12 --technote $oldesttechnoteid |
| 256 | +set anoldtechnoteid [lindex [split [lindex $technotelist [llength $technotelist]-1]] 0] |
| 257 | +fossil wiki export a12 --technote $anoldtechnoteid |
| 246 | 258 | test wiki-40 {[similar_file f12 a12]} |
| 247 | 259 | |
| 248 | 260 | ############################################################################### |
| 249 | 261 | # Also check that we can specify a prefix of the tech note id (note: with |
| 250 | | -# 8 items in the tech note at this point there is a chance of a collision. |
| 251 | | -# However with the chance of the collision being 1 in approx 10^22 if I use a 20 |
| 252 | | -# character prefix I'll ignore that possibility for this test. |
| 253 | | -fossil wiki export a12.1 --technote [string range $oldesttechnoteid 0 20] |
| 262 | +# 9 items in the tech note at this point there is a chance of a collision. |
| 263 | +# However with a 20 character prefix the chance of the collision is |
| 264 | +# approximately 1 in 10^22 so this test ignores that possibility.) |
| 265 | +fossil wiki export a12.1 --technote [string range $anoldtechnoteid 0 20] |
| 254 | 266 | test wiki-41 {[similar_file f12 a12.1]} |
| 255 | 267 | |
| 256 | 268 | ############################################################################### |
| 257 | 269 | # Now we need to force a collision in the first four characters of the tech |
| 258 | 270 | # note id if we don't already have one so we can check we get an error if the |
| | @@ -274,12 +286,12 @@ |
| 274 | 286 | # any other tech note, but after 1 AD |
| 275 | 287 | set i 2400000 |
| 276 | 288 | while {$maxcount < 2} { |
| 277 | 289 | # keep getting older |
| 278 | 290 | incr i -1 |
| 279 | | - write_file collision "A tech note with timestamp of jday=$i" |
| 280 | | - fossil wiki create "timestamp of $i" collision --technote "$i" |
| 291 | + write_file f13 "A tech note with timestamp of jday=$i" |
| 292 | + fossil wiki create "timestamp of $i" f13 --technote "$i" |
| 281 | 293 | fossil wiki list --technote --show-technote-ids |
| 282 | 294 | set technotelist [split $RESULT "\n"] |
| 283 | 295 | set oldesttechnoteid [lindex [split [lindex $technotelist [llength $technotelist]-1]] 0] |
| 284 | 296 | set id [string range $oldesttechnoteid 0 3] |
| 285 | 297 | dict incr idcounts $id |
| | @@ -286,11 +298,32 @@ |
| 286 | 298 | if {[dict get $idcounts $id] > $maxcount} { |
| 287 | 299 | set maxid $id |
| 288 | 300 | incr maxcount |
| 289 | 301 | } |
| 290 | 302 | } |
| 291 | | -fossil wiki export a13 --technote $maxid -expectError |
| 303 | +# Save the duplicate id for this and later tests |
| 304 | +set duplicateid $maxid |
| 305 | +fossil wiki export a13 --technote $duplicateid -expectError |
| 292 | 306 | test wiki-42 {$CODE != 0} |
| 307 | + |
| 308 | +############################################################################### |
| 309 | +# Check we can update technote by its id |
| 310 | +write_file f14 "Updated text for the really old tech note" |
| 311 | +fossil wiki commit {Old tech note} f14 --technote $anoldtechnoteid |
| 312 | +fossil wiki export a14 --technote $anoldtechnoteid |
| 313 | +test wiki-43 {[similar_file f14 a14]} |
| 314 | + |
| 315 | +############################################################################### |
| 316 | +# Also check that we can specify a prefix of the tech note id |
| 317 | +write_file f15 "Updated text for the really old tech note specified by its id" |
| 318 | +fossil wiki commit {Old tech note} f15 --technote [string range $anoldtechnoteid 0 20] |
| 319 | +fossil wiki export a15 --technote $anoldtechnoteid |
| 320 | +test wiki-44 {[similar_file f15 a15]} |
| 321 | + |
| 322 | +############################################################################### |
| 323 | +# And we get an error for the ambiguous tech note id |
| 324 | +fossil wiki commit {Old tech note} f15 --technote $duplicateid -expectError |
| 325 | +test wiki-45 {$CODE != 0} |
| 293 | 326 | |
| 294 | 327 | ############################################################################### |
| 295 | 328 | test_cleanup |
| 296 | 329 | |
| 297 | 330 | |