Skip to content

Commit

Permalink
Show warning when trying to delete a tag that is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-si committed May 5, 2024
1 parent d9dab60 commit 68be391
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tasklite-core/source/Lib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,17 @@ deleteTag conf connection tag ids = do
, ":tag" := tag
]

pure $ getResultMsg ("💥 Removed tag \"" <> pretty tag <> "\"") task
numOfChanges <- changes connection

pure $
if numOfChanges == 0
then
annotate (color Yellow) $
"⚠️ Tag"
<+> dquotes (pretty tag)
<+> "is not set for task"
<+> dquotes (pretty task.ulid)
else getResultMsg ("💥 Removed tag \"" <> pretty tag <> "\"") task

pure $ vsep docs

Expand Down
6 changes: 6 additions & 0 deletions tasklite-core/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ testSuite conf now = do
query_ memConn "SELECT * FROM task_to_tag"
taskToTags `shouldBe` []

it "doesn't delete a tag that does not exist" $ do
withMemoryDb conf $ \memConn -> do
insertRecord "tasks" memConn exampleTask
delResult <- deleteTag conf memConn "test" [exampleTask.ulid]
unpack (show delResult) `shouldContain` "not set"

it "adds a note" $ do
withMemoryDb conf $ \memConn -> do
insertRecord "tasks" memConn exampleTask
Expand Down

0 comments on commit 68be391

Please sign in to comment.