Fossil SCM

fossil-scm / test / wiki.test
Source Blame History 411 lines
05cd9fa… rberteig 1 #
05cd9fa… rberteig 2 # Copyright (c) 2016 D. Richard Hipp
05cd9fa… rberteig 3 #
05cd9fa… rberteig 4 # This program is free software; you can redistribute it and/or
05cd9fa… rberteig 5 # modify it under the terms of the Simplified BSD License (also
05cd9fa… rberteig 6 # known as the "2-Clause License" or "FreeBSD License".)
05cd9fa… rberteig 7 #
05cd9fa… rberteig 8 # This program is distributed in the hope that it will be useful,
05cd9fa… rberteig 9 # but without any warranty; without even the implied warranty of
05cd9fa… rberteig 10 # merchantability or fitness for a particular purpose.
05cd9fa… rberteig 11 #
05cd9fa… rberteig 12 # Author contact information:
05cd9fa… rberteig 13 # [email protected]
05cd9fa… rberteig 14 # http://www.hwaci.com/drh/
05cd9fa… rberteig 15 #
05cd9fa… rberteig 16 ############################################################################
05cd9fa… rberteig 17 #
05cd9fa… rberteig 18 # Test wiki and attachment command Support
05cd9fa… rberteig 19 #
05cd9fa… rberteig 20
05cd9fa… rberteig 21 test_setup
981049f… ashepilko 22
981049f… ashepilko 23 # Disable backoffice for this test, otherwise its process lingers for some
981049f… ashepilko 24 # time after the test has completed.
981049f… ashepilko 25 # Perhaps, this should be done in test_setup and enabled explicitly only
981049f… ashepilko 26 # when needed.
981049f… ashepilko 27 fossil set backoffice-disable 1
b40f1ac… drh 28
05cd9fa… rberteig 29 # Return true if two files are similar (i.e. not only compress trailing spaces
05cd9fa… rberteig 30 # from a line, but remove any final LF from the file as well)
05cd9fa… rberteig 31 proc similar_file {a b} {
93d52a0… rberteig 32 set x ""
93d52a0… rberteig 33 if {[file exists $a]} {
93d52a0… rberteig 34 set x [read_file $a]
93d52a0… rberteig 35 regsub -all { +\n} $x \n x
93d52a0… rberteig 36 regsub -all {\n$} $x {} x
93d52a0… rberteig 37 }
93d52a0… rberteig 38 set y ""
93d52a0… rberteig 39 if {[file exists $b]} {
93d52a0… rberteig 40 set y [read_file $b]
93d52a0… rberteig 41 regsub -all { +\n} $y \n y
93d52a0… rberteig 42 regsub -all {\n$} $y {} y
93d52a0… rberteig 43 }
05cd9fa… rberteig 44 return [expr {$x==$y}]
05cd9fa… rberteig 45 }
05cd9fa… rberteig 46
05cd9fa… rberteig 47 # Return the mime type in the manifest for a given wiki page
05cd9fa… rberteig 48 # Defaults to "error: some text" if the manifest can't be located and
05cd9fa… rberteig 49 # "text/x-fossil-wiki" (the default mimetype for rendering)
05cd9fa… rberteig 50 # if the N card is omitted in the manifest.
05cd9fa… rberteig 51 # Note: Makes fossil calls, so $CODE and $RESULT will be corrupted
05cd9fa… rberteig 52 proc get_mime_type {name} {
05cd9fa… rberteig 53 global CODE RESULT
05cd9fa… rberteig 54 fossil http << "GET /wiki?name=$name"
05cd9fa… rberteig 55 if {$CODE != 0} {
b40f1ac… drh 56 return "error: /wiki?name=$name $CODE $RESULT"
b40f1ac… drh 57 }
b40f1ac… drh 58 fossil whatis --type w $name
b40f1ac… drh 59 if {$CODE != 0} {
b40f1ac… drh 60 return "error: fossil whatis --type w $name $CODE $RESULT"
05cd9fa… rberteig 61 }
b40f1ac… drh 62 set CODE [regexp -line {^artifact:\s*([0-9a-f]+)$} $RESULT match info]
05cd9fa… rberteig 63 if {$CODE == 0} {
b40f1ac… drh 64 return "error: whatis returned no info for wiki page $name"
05cd9fa… rberteig 65 }
b40f1ac… drh 66 fossil artifact $info
05cd9fa… rberteig 67 if {$CODE != 0} {
b40f1ac… drh 68 return "error: fossil artifact $info $CODE $RESULT"
05cd9fa… rberteig 69 }
b40f1ac… drh 70 set CODE [regexp -line {^N (.*)$} $RESULT match mimetype]
05cd9fa… rberteig 71 if {$CODE == 0} {
05cd9fa… rberteig 72 return "text/x-fossil-wiki"
05cd9fa… rberteig 73 }
05cd9fa… rberteig 74 return $mimetype
05cd9fa… rberteig 75 }
05cd9fa… rberteig 76
05cd9fa… rberteig 77
05cd9fa… rberteig 78 ###############################################################################
05cd9fa… rberteig 79 # Initially there should be no wiki entries
05cd9fa… rberteig 80 fossil wiki list
05cd9fa… rberteig 81 test wiki-0 {[normalize_result] eq {}}
05cd9fa… rberteig 82
05cd9fa… rberteig 83 ###############################################################################
05cd9fa… rberteig 84 # Adding an entry should add it to the wiki list
05cd9fa… rberteig 85 write_file f1 "first wiki note"
05cd9fa… rberteig 86 fossil wiki create tcltest f1
05cd9fa… rberteig 87 test wiki-1 {$CODE == 0}
05cd9fa… rberteig 88 fossil wiki list
05cd9fa… rberteig 89 test wiki-2 {[normalize_result] eq {tcltest}}
05cd9fa… rberteig 90
05cd9fa… rberteig 91 ###############################################################################
05cd9fa… rberteig 92 # Trying to add the same entry should fail
05cd9fa… rberteig 93 fossil wiki create tcltest f1 -expectError
05cd9fa… rberteig 94 test wiki-3 {$CODE != 0}
05cd9fa… rberteig 95
05cd9fa… rberteig 96 ###############################################################################
05cd9fa… rberteig 97 # exporting the wiki page should give back similar text
05cd9fa… rberteig 98 fossil wiki export tcltest a1
05cd9fa… rberteig 99 test wiki-4 {[similar_file f1 a1]}
05cd9fa… rberteig 100
05cd9fa… rberteig 101 ###############################################################################
05cd9fa… rberteig 102 # commiting a change to an existing page should replace the page on export
05cd9fa… rberteig 103 write_file f2 "second version of the page"
05cd9fa… rberteig 104 fossil wiki commit tcltest f2
05cd9fa… rberteig 105 test wiki-5 {$CODE == 0}
05cd9fa… rberteig 106 fossil wiki export tcltest a2
05cd9fa… rberteig 107 test wiki-6 {[similar_file f2 a2]}
05cd9fa… rberteig 108
05cd9fa… rberteig 109 ###############################################################################
05cd9fa… rberteig 110 # But we shouldn't be able to update non-existant pages
05cd9fa… rberteig 111 fossil wiki commit doesntexist f1 -expectError
05cd9fa… rberteig 112 test wiki-7 {$CODE != 0}
05cd9fa… rberteig 113
05cd9fa… rberteig 114 ###############################################################################
05cd9fa… rberteig 115 # There shouldn't be any tech notes at this point
05cd9fa… rberteig 116 fossil wiki list --technote
05cd9fa… rberteig 117 test wiki-8 {[normalize_result] eq {}}
05cd9fa… rberteig 118
05cd9fa… rberteig 119 ###############################################################################
05cd9fa… rberteig 120 # Creating a tech note with a specified timestamp should add a technote
05cd9fa… rberteig 121 write_file f3 "A technote"
05cd9fa… rberteig 122 fossil wiki create technote f3 --technote {2016-01-01 12:34}
05cd9fa… rberteig 123 test wiki-9 {$CODE == 0}
05cd9fa… rberteig 124 fossil wiki list --technote
05cd9fa… rberteig 125 test wiki-10 {[normalize_result] eq {2016-01-01 12:34:00}}
05cd9fa… rberteig 126 fossil wiki list --technote --show-technote-ids
05cd9fa… rberteig 127 set technotelist [split $RESULT "\n"]
05cd9fa… rberteig 128 set veryfirsttechnoteid [lindex [split [lindex $technotelist 0]] 0]
05cd9fa… rberteig 129
05cd9fa… rberteig 130 ###############################################################################
05cd9fa… rberteig 131 # exporting that technote should give back similar text
05cd9fa… rberteig 132 fossil wiki export a3 --technote {2016-01-01 12:34:00}
05cd9fa… rberteig 133 test wiki-11 {[similar_file f3 a3]}
05cd9fa… rberteig 134
05cd9fa… rberteig 135 ###############################################################################
05cd9fa… rberteig 136 # Trying to add a technote with the same timestamp should succeed and create a
05cd9fa… rberteig 137 # second tech note
05cd9fa… rberteig 138 fossil wiki create 2ndnote f3 -technote {2016-01-01 12:34}
05cd9fa… rberteig 139 test wiki-13 {$CODE == 0}
05cd9fa… rberteig 140 fossil wiki list --technote
d32155d… jan.nijtmans 141 set technotelist [split $RESULT "\n"]
05cd9fa… rberteig 142 test wiki-13.1 {[llength $technotelist] == 2}
05cd9fa… rberteig 143
05cd9fa… rberteig 144 ###############################################################################
05cd9fa… rberteig 145 # commiting a change to an existing technote should replace the page on export
05cd9fa… rberteig 146 # (this should update the tech note from wiki-13 as that the most recently
05cd9fa… rberteig 147 # updated one, that should also be the one exported by the export command)
05cd9fa… rberteig 148 write_file f4 "technote 2nd variant"
05cd9fa… rberteig 149 fossil wiki commit technote f4 --technote {2016-01-01 12:34}
05cd9fa… rberteig 150 test wiki-14 {$CODE == 0}
05cd9fa… rberteig 151 fossil wiki export a4 --technote {2016-01-01 12:34}
05cd9fa… rberteig 152 test wiki-15 {[similar_file f4 a4]}
05cd9fa… rberteig 153 # Also check that the tech note with the same timestamp, but modified less
05cd9fa… rberteig 154 # recently still has its original text
05cd9fa… rberteig 155 fossil wiki export a4.1 --technote $veryfirsttechnoteid
05cd9fa… rberteig 156 test wiki-15.1 {[similar_file f3 a4.1]}
05cd9fa… rberteig 157
05cd9fa… rberteig 158 ###############################################################################
05cd9fa… rberteig 159 # But we shouldn't be able to update non-existant pages
05cd9fa… rberteig 160 fossil wiki commit doesntexist f1 -expectError
05cd9fa… rberteig 161 test wiki-16 {$CODE != 0}
05cd9fa… rberteig 162
05cd9fa… rberteig 163 ###############################################################################
d32155d… jan.nijtmans 164 # Check specifying tags for a technote is OK
05cd9fa… rberteig 165 write_file f5 "technote with tags"
05cd9fa… rberteig 166 fossil wiki create {tagged technote} f5 --technote {2016-01-02 12:34} --technote-tags {A B}
05cd9fa… rberteig 167 test wiki-17 {$CODE == 0}
05cd9fa… rberteig 168 write_file f5.1 "editted and tagged technote"
05cd9fa… rberteig 169 fossil wiki commit {tagged technote} f5 --technote {2016-01-02 12:34} --technote-tags {C D}
05cd9fa… rberteig 170 test wiki-18 {$CODE == 0}
05cd9fa… rberteig 171
05cd9fa… rberteig 172 ###############################################################################
05cd9fa… rberteig 173 # Check specifying a bgcolor for a technote is OK
05cd9fa… rberteig 174 write_file f6 "bgcolored technote"
05cd9fa… rberteig 175 fossil wiki create bgcolor f6 --technote {2016-01-03 12:34} --technote-bgcolor red
05cd9fa… rberteig 176 test wiki-19 {$CODE == 0}
05cd9fa… rberteig 177 write_file f6.1 "editted technote with a background color"
05cd9fa… rberteig 178 fossil wiki commit bgcolor f6.1 --technote {2016-01-03 12:34} --technote-bgcolor yellow
05cd9fa… rberteig 179 test wiki-20 {$CODE == 0}
05cd9fa… rberteig 180
05cd9fa… rberteig 181 ###############################################################################
05cd9fa… rberteig 182 # Test adding an attachment to both a non-existant (should fail) and existing wiki page
05cd9fa… rberteig 183 write_file fa "This is a file to be attached"
05cd9fa… rberteig 184 fossil attachment add doesntexist fa -expectError
05cd9fa… rberteig 185 test wiki-21 {$CODE != 0}
05cd9fa… rberteig 186 fossil attachment add tcltest fa
05cd9fa… rberteig 187 test wiki-22 {$CODE == 0}
05cd9fa… rberteig 188
05cd9fa… rberteig 189 ###############################################################################
05cd9fa… rberteig 190 # Test adding an attachment to both a non-existant (should fail) and existing tech note
05cd9fa… rberteig 191 fossil attachment add fa --technote {2016-07-22 12:00} -expectError
05cd9fa… rberteig 192 test wiki-23 {$CODE != 0}
05cd9fa… rberteig 193 fossil attachment add fa --technote {2016-01-03 12:34}
05cd9fa… rberteig 194 test wiki-24 {$CODE == 0}
05cd9fa… rberteig 195
05cd9fa… rberteig 196 ###############################################################################
05cd9fa… rberteig 197 # Check that a wiki page with an attachment can be updated
05cd9fa… rberteig 198 fossil wiki commit tcltest f1
05cd9fa… rberteig 199 test wiki-25 {$CODE == 0}
05cd9fa… rberteig 200
05cd9fa… rberteig 201 ###############################################################################
05cd9fa… rberteig 202 # Check that a technote with an attachment can be updated
05cd9fa… rberteig 203 fossil wiki commit technote f6 --technote {2016-01-03 12:34}
05cd9fa… rberteig 204 test wiki-26 {$CODE == 0}
05cd9fa… rberteig 205 fossil wiki commit technote f6 --technote {2016-01-03 12:34} --technote-tags {E F}
05cd9fa… rberteig 206 test wiki-27 {$CODE == 0}
05cd9fa… rberteig 207 fossil wiki commit technote f6 --technote {2016-01-03 12:34} --technote-bgcolor blue
05cd9fa… rberteig 208 test wiki-28 {$CODE == 0}
05cd9fa… rberteig 209
05cd9fa… rberteig 210 ###############################################################################
05cd9fa… rberteig 211 # Check longest form of timestamp for the technote
05cd9fa… rberteig 212 write_file f7 "Different timestamps"
05cd9fa… rberteig 213 fossil wiki create technotenow f7 --technote {2016-01-04 12:34:56+00:00}
05cd9fa… rberteig 214 test wiki-29 {$CODE == 0}
05cd9fa… rberteig 215
05cd9fa… rberteig 216 ###############################################################################
05cd9fa… rberteig 217 # Check a technote appears on the timeline
05cd9fa… rberteig 218 write_file f8 "Contents of a 'unique' tech note"
05cd9fa… rberteig 219 fossil wiki create {Unique technote} f8 --technote {2016-01-05 01:02:03}
05cd9fa… rberteig 220 fossil timeline
05cd9fa… rberteig 221 test wiki-30 {[string match *Unique*technote* $RESULT]}
05cd9fa… rberteig 222
05cd9fa… rberteig 223 ###############################################################################
05cd9fa… rberteig 224 # Check for a collision between an attachment and a note, this was a
d32155d… jan.nijtmans 225 # bug that resulted from some code treating the attachment entry as if it
d32155d… jan.nijtmans 226 # were a technote when it isn't really.
05cd9fa… rberteig 227 #
05cd9fa… rberteig 228 # First, wait for the top of the next second so the attachment
05cd9fa… rberteig 229 # happens at a known time, then add an attachment to an existing note
d32155d… jan.nijtmans 230 # and a new note immediately after.
05cd9fa… rberteig 231
05cd9fa… rberteig 232 set t0 [clock seconds]
05cd9fa… rberteig 233 while {$t0 == [clock seconds]} {
05cd9fa… rberteig 234 after 100
05cd9fa… rberteig 235 }
05cd9fa… rberteig 236 set t1 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
05cd9fa… rberteig 237 write_file f9 "Timestamp: $t1"
05cd9fa… rberteig 238 fossil attachment add f9 --technote {2016-01-05 01:02:03}
05cd9fa… rberteig 239 test wiki-31 {$CODE == 0}
05cd9fa… rberteig 240 fossil wiki create {Attachment collision} f9 --technote now
05cd9fa… rberteig 241 test wiki-32 {$CODE == 0}
05cd9fa… rberteig 242 #
05cd9fa… rberteig 243 # Now waste time until the next second so that the remaining tests
05cd9fa… rberteig 244 # don't have to worry about a potential collision
05cd9fa… rberteig 245 set t0 [clock seconds]
05cd9fa… rberteig 246 while {$t0 == [clock seconds]} {
05cd9fa… rberteig 247 after 100
05cd9fa… rberteig 248 }
05cd9fa… rberteig 249
05cd9fa… rberteig 250 ###############################################################################
05cd9fa… rberteig 251 # Check a technote with no timestamp cannot be created, but that
05cd9fa… rberteig 252 # "now" is a valid stamp.
05cd9fa… rberteig 253 set t2 [clock format [clock seconds] -gmt 1 -format "%Y-%m-%d %H:%M:%S"]
05cd9fa… rberteig 254 write_file f10 "Even unstampted notes are delivered.\nStamped $t2"
05cd9fa… rberteig 255 fossil wiki create "Unstamped Note" f10 --technote -expectError
05cd9fa… rberteig 256 test wiki-33 {$CODE != 0}
05cd9fa… rberteig 257 fossil wiki create "Unstamped Note" f10 --technote now
05cd9fa… rberteig 258 test wiki-34 {$CODE == 0}
d32155d… jan.nijtmans 259 fossil wiki list -t
05cd9fa… rberteig 260 test wiki-35 {[string match "*$t2*" $RESULT]}
05cd9fa… rberteig 261
05cd9fa… rberteig 262 ###############################################################################
d32155d… jan.nijtmans 263 # Check an attachment to it in the same second works.
05cd9fa… rberteig 264 write_file f11 "Time Stamp was $t2"
05cd9fa… rberteig 265 fossil attachment add f11 --technote $t2
05cd9fa… rberteig 266 test wiki-36 {$CODE == 0}
05cd9fa… rberteig 267 fossil timeline
05cd9fa… rberteig 268 test wiki-36-1 {$CODE == 0}
05cd9fa… rberteig 269 fossil wiki list -t
05cd9fa… rberteig 270 test wiki-36-2 {$CODE == 0}
05cd9fa… rberteig 271
05cd9fa… rberteig 272 ###############################################################################
d32155d… jan.nijtmans 273 # Check that we have the expected number of tech notes on the list (and not
d32155d… jan.nijtmans 274 # extra ones from other events (such as the attachments) - 8 tech notes
d32155d… jan.nijtmans 275 # expected created by tests 9, 13, 17, 19, 29, 31, 32 and 34
05cd9fa… rberteig 276 fossil wiki list --technote
d32155d… jan.nijtmans 277 set technotelist [split $RESULT "\n"]
05cd9fa… rberteig 278 test wiki-37 {[llength $technotelist] == 8}
05cd9fa… rberteig 279
05cd9fa… rberteig 280 ###############################################################################
05cd9fa… rberteig 281 # Check that using the show-technote-ids shows the same tech notes in the same
05cd9fa… rberteig 282 # order (with the technote id as the first word of the line)
05cd9fa… rberteig 283 fossil wiki list --technote --show-technote-ids
05cd9fa… rberteig 284 set technoteidlist [split $RESULT "\n"]
05cd9fa… rberteig 285 test wiki-38 {[llength $technotelist] == 8}
05cd9fa… rberteig 286 for {set i 0} {$i < [llength $technotelist]} {incr i} {
05cd9fa… rberteig 287 set match "???????????????????????????????????????? "
05cd9fa… rberteig 288 append match [lindex $technotelist $i]
05cd9fa… rberteig 289 test "wiki-39-$i" {[string match $match [lindex $technoteidlist $i]]}
05cd9fa… rberteig 290 }
05cd9fa… rberteig 291
05cd9fa… rberteig 292 ###############################################################################
05cd9fa… rberteig 293 # Create new tech note with a old timestamp so that it is oldest and then check that
05cd9fa… rberteig 294 # the contents of the oldest tech note (by tech note id, both full and short) match up
05cd9fa… rberteig 295 write_file f12 "A really old tech note"
05cd9fa… rberteig 296 fossil wiki create {Old tech note} f12 --technote {2001-07-07 09:08:07}
05cd9fa… rberteig 297 fossil wiki list --technote --show-technote-ids
05cd9fa… rberteig 298 set technotelist [split $RESULT "\n"]
05cd9fa… rberteig 299 set anoldtechnoteid [lindex [split [lindex $technotelist [llength $technotelist]-1]] 0]
05cd9fa… rberteig 300 fossil wiki export a12 --technote $anoldtechnoteid
05cd9fa… rberteig 301 test wiki-40 {[similar_file f12 a12]}
05cd9fa… rberteig 302
05cd9fa… rberteig 303 ###############################################################################
05cd9fa… rberteig 304 # Also check that we can specify a prefix of the tech note id (note: with
05cd9fa… rberteig 305 # 9 items in the tech note at this point there is a chance of a collision.
d32155d… jan.nijtmans 306 # However with a 20 character prefix the chance of the collision is
05cd9fa… rberteig 307 # approximately 1 in 10^22 so this test ignores that possibility.)
05cd9fa… rberteig 308 fossil wiki export a12.1 --technote [string range $anoldtechnoteid 0 20]
05cd9fa… rberteig 309 test wiki-41 {[similar_file f12 a12.1]}
05cd9fa… rberteig 310
05cd9fa… rberteig 311 ###############################################################################
05cd9fa… rberteig 312 # Now we need to force a collision in the first four characters of the tech
05cd9fa… rberteig 313 # note id if we don't already have one so we can check we get an error if the
05cd9fa… rberteig 314 # tech note id is ambiguous
05cd9fa… rberteig 315 set idcounts [dict create]
05cd9fa… rberteig 316 set maxcount 0
05cd9fa… rberteig 317 fossil wiki list --technote --show-technote-ids
05cd9fa… rberteig 318 set technotelist [split $RESULT "\n"]
05cd9fa… rberteig 319 for {set i 0} {$i < [llength $technotelist]} {incr i} {
05cd9fa… rberteig 320 set fullid [lindex $technotelist $i]
05cd9fa… rberteig 321 set id [string range $fullid 0 3]
05cd9fa… rberteig 322 dict incr idcounts $id
05cd9fa… rberteig 323 if {[dict get $idcounts $id] > $maxcount} {
05cd9fa… rberteig 324 set maxid $id
d32155d… jan.nijtmans 325 incr maxcount
05cd9fa… rberteig 326 }
05cd9fa… rberteig 327 }
05cd9fa… rberteig 328 # get i so that, as a julian date, it is in the 1800s, i.e., older than
05cd9fa… rberteig 329 # any other tech note, but after 1 AD
05cd9fa… rberteig 330 set i 2400000
05cd9fa… rberteig 331 while {$maxcount < 2} {
05cd9fa… rberteig 332 # keep getting older
05cd9fa… rberteig 333 incr i -1
05cd9fa… rberteig 334 write_file f13 "A tech note with timestamp of jday=$i"
05cd9fa… rberteig 335 fossil wiki create "timestamp of $i" f13 --technote "$i"
05cd9fa… rberteig 336 fossil wiki list --technote --show-technote-ids
05cd9fa… rberteig 337 set technotelist [split $RESULT "\n"]
05cd9fa… rberteig 338 set oldesttechnoteid [lindex [split [lindex $technotelist [llength $technotelist]-1]] 0]
05cd9fa… rberteig 339 set id [string range $oldesttechnoteid 0 3]
05cd9fa… rberteig 340 dict incr idcounts $id
05cd9fa… rberteig 341 if {[dict get $idcounts $id] > $maxcount} {
05cd9fa… rberteig 342 set maxid $id
d32155d… jan.nijtmans 343 incr maxcount
05cd9fa… rberteig 344 }
05cd9fa… rberteig 345 }
05cd9fa… rberteig 346 # Save the duplicate id for this and later tests
05cd9fa… rberteig 347 set duplicateid $maxid
05cd9fa… rberteig 348 fossil wiki export a13 --technote $duplicateid -expectError
05cd9fa… rberteig 349 test wiki-42 {$CODE != 0}
05cd9fa… rberteig 350
05cd9fa… rberteig 351 ###############################################################################
05cd9fa… rberteig 352 # Check we can update technote by its id
05cd9fa… rberteig 353 write_file f14 "Updated text for the really old tech note"
05cd9fa… rberteig 354 fossil wiki commit {Old tech note} f14 --technote $anoldtechnoteid
05cd9fa… rberteig 355 fossil wiki export a14 --technote $anoldtechnoteid
05cd9fa… rberteig 356 test wiki-43 {[similar_file f14 a14]}
05cd9fa… rberteig 357
05cd9fa… rberteig 358 ###############################################################################
05cd9fa… rberteig 359 # Check we can add attachments to a technote by its id
05cd9fa… rberteig 360 fossil attachment add fa --technote $anoldtechnoteid
05cd9fa… rberteig 361 test wiki-44 {$CODE == 0}
05cd9fa… rberteig 362
05cd9fa… rberteig 363 ###############################################################################
05cd9fa… rberteig 364 # Also check that we can specify a prefix of the tech note id
05cd9fa… rberteig 365 write_file f15 "Updated text for the really old tech note specified by its id"
05cd9fa… rberteig 366 fossil wiki commit {Old tech note} f15 --technote [string range $anoldtechnoteid 0 20]
05cd9fa… rberteig 367 fossil wiki export a15 --technote $anoldtechnoteid
05cd9fa… rberteig 368 test wiki-45 {[similar_file f15 a15]}
05cd9fa… rberteig 369
05cd9fa… rberteig 370 ###############################################################################
05cd9fa… rberteig 371 # Check we can add attachments to a technote by a prefix of its id
05cd9fa… rberteig 372 fossil attachment add fa --technote [string range $anoldtechnoteid 0 20]
05cd9fa… rberteig 373 test wiki-46 {$CODE == 0}
05cd9fa… rberteig 374
05cd9fa… rberteig 375 ###############################################################################
05cd9fa… rberteig 376 # And we get an error for the ambiguous tech note id
05cd9fa… rberteig 377 fossil wiki commit {Old tech note} f15 --technote $duplicateid -expectError
05cd9fa… rberteig 378 test wiki-47 {$CODE != 0}
05cd9fa… rberteig 379 fossil attachment add fa --technote $duplicateid -expectError
05cd9fa… rberteig 380 test wiki-48 {$CODE != 0}
05cd9fa… rberteig 381
05cd9fa… rberteig 382 ###############################################################################
05cd9fa… rberteig 383 # Check the default mimetype is text/x-fossil-wiki
05cd9fa… rberteig 384 test wiki-49 {[get_mime_type tcltest] == "text/x-fossil-wiki"}
05cd9fa… rberteig 385
05cd9fa… rberteig 386 ###############################################################################
05cd9fa… rberteig 387 # Check long form of the mimetypes are recorded correctly
05cd9fa… rberteig 388 fossil wiki create tcltest-x-fossil f1 -mimetype text/x-fossil-wiki
05cd9fa… rberteig 389 test wiki-50 {[get_mime_type tcltest-x-fossil] == "text/x-fossil-wiki"}
05cd9fa… rberteig 390 fossil wiki create tcltest-x-markdown f1 -mimetype text/x-markdown
05cd9fa… rberteig 391 test wiki-51 {[get_mime_type tcltest-x-markdown] == "text/x-markdown"}
05cd9fa… rberteig 392 fossil wiki create tcltest-plain f1 -mimetype text/plain
05cd9fa… rberteig 393 test wiki-52 {[get_mime_type tcltest-plain] == "text/plain"}
05cd9fa… rberteig 394 fossil wiki create tcltest-x-random f1 -mimetype text/x-random
05cd9fa… rberteig 395 test wiki-53 {[get_mime_type tcltest-x-random] == "text/x-fossil-wiki"}
05cd9fa… rberteig 396
05cd9fa… rberteig 397 ###############################################################################
05cd9fa… rberteig 398 # Check short form of the mimetypes are recorded correctly
05cd9fa… rberteig 399 fossil wiki create tcltest-x-fossil-short f1 -mimetype wiki
05cd9fa… rberteig 400 test wiki-54 {[get_mime_type tcltest-x-fossil-short] == "text/x-fossil-wiki"}
05cd9fa… rberteig 401 fossil wiki create tcltest-x-markdown-short f1 -mimetype markdown
05cd9fa… rberteig 402 test wiki-55 {[get_mime_type tcltest-x-markdown-short] == "text/x-markdown"}
05cd9fa… rberteig 403 fossil wiki create tcltest-plain-short f1 -mimetype plain
05cd9fa… rberteig 404 test wiki-56 {[get_mime_type tcltest-plain-short] == "text/plain"}
05cd9fa… rberteig 405 fossil wiki create tcltest-x-random-short f1 -mimetype random
05cd9fa… rberteig 406 test wiki-57 {[get_mime_type tcltest-x-random-short] == "text/x-fossil-wiki"}
05cd9fa… rberteig 407
05cd9fa… rberteig 408
05cd9fa… rberteig 409 ###############################################################################
05cd9fa… rberteig 410 test_cleanup
05cd9fa… rberteig 411

Keyboard Shortcuts

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