• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

CLI interface to medialist (fossil mirror)


Commit MetaInfo

Révision01790d4c361099590d8e1d1d47ca811ddc4f5077 (tree)
l'heure2021-11-25 13:20:59
Auteurmio <stigma@disr...>
Commitermio

Message de Log

Add a unittest for checking the "last_updated" field.

FossilOrigin-Name: 4d3278db24d5418bb02b26fc605e06e7921248b2dee29a15ea6996538d4c4cb9

Change Summary

Modification

--- a/update.d
+++ b/update.d
@@ -396,8 +396,8 @@ unittest
396396 }
397397
398398 /*
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.
401401 */
402402 unittest
403403 {
@@ -409,8 +409,8 @@ unittest
409409 import create : handle_create;
410410 import update : handle_update;
411411
412- immutable listName = "unittest-8c28f8b0aa";
413- immutable progName = "medialist-cli-unittest-8c28f8b0aa";
412+ immutable listName = "unittest-d2ed4a04d0";
413+ immutable progName = "medialist-cli-unittest-d2ed4a04d0";
414414 immutable currDir = getcwd();
415415
416416 handle_create (progName, listName, currDir);
@@ -451,3 +451,40 @@ unittest
451451 assert ("2021-11-25" == sections[4], "\"2021-11-25\" == sections[4]");
452452 }
453453
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+