CLI interface to medialist (fossil mirror)
Révision | 01790d4c361099590d8e1d1d47ca811ddc4f5077 (tree) |
---|---|
l'heure | 2021-11-25 13:20:59 |
Auteur | mio <stigma@disr...> |
Commiter | mio |
Add a unittest for checking the "last_updated" field.
FossilOrigin-Name: 4d3278db24d5418bb02b26fc605e06e7921248b2dee29a15ea6996538d4c4cb9
@@ -396,8 +396,8 @@ unittest | ||
396 | 396 | } |
397 | 397 | |
398 | 398 | /* |
399 | - * Ticket 8c28f8b0aa | |
400 | - * Update the "last_updated" field when updating the items. | |
399 | + * Ticket d2ed4a04d0 | |
400 | + * Manually update the "start_date" and "end_date" fields of an item. | |
401 | 401 | */ |
402 | 402 | unittest |
403 | 403 | { |
@@ -409,8 +409,8 @@ unittest | ||
409 | 409 | import create : handle_create; |
410 | 410 | import update : handle_update; |
411 | 411 | |
412 | - immutable listName = "unittest-8c28f8b0aa"; | |
413 | - immutable progName = "medialist-cli-unittest-8c28f8b0aa"; | |
412 | + immutable listName = "unittest-d2ed4a04d0"; | |
413 | + immutable progName = "medialist-cli-unittest-d2ed4a04d0"; | |
414 | 414 | immutable currDir = getcwd(); |
415 | 415 | |
416 | 416 | handle_create (progName, listName, currDir); |
@@ -451,3 +451,40 @@ unittest | ||
451 | 451 | assert ("2021-11-25" == sections[4], "\"2021-11-25\" == sections[4]"); |
452 | 452 | } |
453 | 453 | |
454 | +/* | |
455 | + * Ticket 8c28f8b0aa | |
456 | + * Update the "last_updated" field automatically. I can't really test this since | |
457 | + * the value would only change if the "update" command was run on a different day | |
458 | + * to when the item was added/last updated. | |
459 | + */ | |
460 | +unittest | |
461 | +{ | |
462 | + import std.datetime.systime : Clock; | |
463 | + import std.datetime.date : Date; | |
464 | + import std.file : getcwd, remove; | |
465 | + import std.stdio : File; | |
466 | + import std.string : split, strip; | |
467 | + | |
468 | + import add : handle_add; | |
469 | + import create : handle_create; | |
470 | + import update : handle_update; | |
471 | + | |
472 | + immutable listName = "unittest-8c28f8b0aa"; | |
473 | + immutable progName = "medialist-cli-unittest-8c28f8b0aa"; | |
474 | + immutable currDir = getcwd(); | |
475 | + immutable currDate = cast(Date)Clock.currTime(); | |
476 | + | |
477 | + handle_create (progName, listName, currDir); | |
478 | + handle_add (progName, [listName, "Item 1"], currDir); | |
479 | + | |
480 | + File listFile = File(listName ~ ".tsv"); | |
481 | + scope(exit) remove(listName ~ ".tsv"); | |
482 | + | |
483 | + listFile.readln(); | |
484 | + | |
485 | + string[] sections = listFile.readln().strip().split("\t"); | |
486 | + | |
487 | + Date lastUpdated = Date.fromISOExtString(sections[$ - 1]); | |
488 | + assert(currDate == lastUpdated, "currDate == lastUpdated"); | |
489 | +} | |
490 | + |