From 26d3e71c4e4ea01bce7312a47d124b76b71f6c33 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Sun, 1 May 2022 14:07:18 +0100 Subject: [PATCH] fix test for /t --- tests/ChatTests.hs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/ChatTests.hs b/tests/ChatTests.hs index f37411b166..87ff663ea3 100644 --- a/tests/ChatTests.hs +++ b/tests/ChatTests.hs @@ -478,11 +478,13 @@ testGroup2 = alice <# "dan> hi" alice <# "@dan hey" alice ##> "/t 5" - alice <# "#club cath> hey" - alice <# "#club dan> how is it going?" - alice <# "dan> hi" - alice <# "#club hello" - alice <# "@dan hey" + alice -- these strings are expected in any order because of sorting by time + <##? [ "#club cath> hey", + "#club dan> how is it going?", + "#club hello", + "dan> hi", + "@dan hey" + ] -- remove member cath ##> "/rm club dan" concurrentlyN_ @@ -1919,14 +1921,20 @@ send TestCC {chatController = cc} cmd = atomically $ writeTBQueue (inputQ cc) cm (<##) :: TestCC -> String -> Expectation cc <## line = getTermLine cc `shouldReturn` line -(<###) :: TestCC -> [String] -> Expectation -_ <### [] = pure () -cc <### ls = do - line <- getTermLine cc +getInAnyOrder :: (String -> String) -> TestCC -> [String] -> Expectation +getInAnyOrder _ _ [] = pure () +getInAnyOrder f cc ls = do + line <- f <$> getTermLine cc if line `elem` ls - then cc <### filter (/= line) ls + then getInAnyOrder f cc $ filter (/= line) ls else error $ "unexpected output: " <> line +(<###) :: TestCC -> [String] -> Expectation +(<###) = getInAnyOrder id + +(<##?) :: TestCC -> [String] -> Expectation +(<##?) = getInAnyOrder dropTime + (<#) :: TestCC -> String -> Expectation cc <# line = (dropTime <$> getTermLine cc) `shouldReturn` line