owenrusk.dev

casebench

test cases straight onto the board.

git clone https://owenrusk.dev/casebench.git

commit acdd9af863691b9e6adf5e8d345bda9d305b559b
parent 9049b37506a3b5fa1e6e4fac6c08ed6c750e14c4
author Owen Rusk <owen@papermothgames.com>
date   2026-07-14 11:52:06 -0500
note: refuse empty notes

an empty -f file put a blank note on every board. trailing whitespace goes too.
casebench/cli.py+3-1
tests/test_commands.py+6-0
diff --git a/casebench/cli.py b/casebench/cli.py
index d58316a..24e4290 100644
--- a/casebench/cli.py
+++ b/casebench/cli.py
@@ -118,7 +118,9 @@ def run_put(store: Store, args: argparse.Namespace) -> None:
 
 
 def run_note(store: Store, args: argparse.Namespace) -> None:
-    text = args.file.read_text(encoding="utf-8") if args.file else args.text
+    text = (args.file.read_text(encoding="utf-8") if args.file else args.text).rstrip()
+    if not text:
+        raise Fail("nothing to write")
     players = targets(store, args)
     for who in players:
         on_board(store, who, args.case)
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 92ed6d7..b3cd77a 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -79,6 +79,12 @@ class NoteTest(unittest.TestCase):
         self.assertEqual(code, 1)
         self.assertIn("no item hat", err)
 
+    def test_empty_note(self):
+        code, _, err = run(self.store, "note", "test-lost-umbrella", "  \n", "--player", "owen")
+        self.assertEqual(code, 1)
+        self.assertIn("nothing to write", err)
+        self.assertEqual(self.store.notes(self.owen, "test-lost-umbrella"), [])
+
     def test_case_not_on_board(self):
         code, _, err = run(self.store, "note", "test-other", "x", "--player", "owen")
         self.assertEqual(code, 1)