diff --git a/tasklite-core/source/Lib.hs b/tasklite-core/source/Lib.hs index e68f6c3..9e7ce24 100644 --- a/tasklite-core/source/Lib.hs +++ b/tasklite-core/source/Lib.hs @@ -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 diff --git a/tasklite-core/test/Spec.hs b/tasklite-core/test/Spec.hs index fc8e574..526b960 100644 --- a/tasklite-core/test/Spec.hs +++ b/tasklite-core/test/Spec.hs @@ -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