core: fix group link tests sporadically failing due to non deterministic events order (#1353)

This commit is contained in:
JRoberts
2022-11-12 14:13:34 +04:00
committed by GitHub
parent 8d0ec01a9b
commit 8b794b2285

View File

@@ -17,7 +17,7 @@ import qualified Data.Aeson as J
import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as LB import qualified Data.ByteString.Lazy.Char8 as LB
import Data.Char (isDigit) import Data.Char (isDigit)
import Data.List (isPrefixOf) import Data.List (isPrefixOf, isSuffixOf)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Data.String import Data.String
import qualified Data.Text as T import qualified Data.Text as T
@@ -3518,18 +3518,20 @@ testGroupLink =
alice <## "cath_1 (Catherine): accepting request to join group #team..." alice <## "cath_1 (Catherine): accepting request to join group #team..."
-- if contact existed it is merged -- if contact existed it is merged
concurrentlyN_ concurrentlyN_
[ do [ alice
alice <## "cath_1 (Catherine): contact is connected" <### [ "cath_1 (Catherine): contact is connected",
alice <## "cath_1 invited to group #team via your group link" "contact cath_1 is merged into cath",
alice <## "contact cath_1 is merged into cath" "use @cath <message> to send messages",
alice <## "use @cath <message> to send messages" EndsWith "invited to group #team via your group link",
alice <## "#team: cath joined the group", EndsWith "joined the group"
do ],
cath <## "alice_1 (Alice): contact is connected" cath
cath <## "contact alice_1 is merged into alice" <### [ "alice_1 (Alice): contact is connected",
cath <## "use @alice <message> to send messages" "contact alice_1 is merged into alice",
cath <## "#team: you joined the group" "use @alice <message> to send messages",
cath <## "#team: member bob (Bob) is connected", "#team: you joined the group",
"#team: member bob (Bob) is connected"
],
do do
bob <## "#team: alice added cath (Catherine) to the group (connecting...)" bob <## "#team: alice added cath (Catherine) to the group (connecting...)"
bob <## "#team: new member cath is connected" bob <## "#team: new member cath is connected"
@@ -3596,17 +3598,19 @@ testGroupLinkDeleteGroupRejoin =
bob <## "connection request sent!" bob <## "connection request sent!"
alice <## "bob_1 (Bob): accepting request to join group #team..." alice <## "bob_1 (Bob): accepting request to join group #team..."
concurrentlyN_ concurrentlyN_
[ do [ alice
alice <## "bob_1 (Bob): contact is connected" <### [ "bob_1 (Bob): contact is connected",
alice <## "bob_1 invited to group #team via your group link" "contact bob_1 is merged into bob",
alice <## "contact bob_1 is merged into bob" "use @bob <message> to send messages",
alice <## "use @bob <message> to send messages" EndsWith "invited to group #team via your group link",
alice <## "#team: bob joined the group", EndsWith "joined the group"
do ],
bob <## "alice_1 (Alice): contact is connected" bob
bob <## "contact alice_1 is merged into alice" <### [ "alice_1 (Alice): contact is connected",
bob <## "use @alice <message> to send messages" "contact alice_1 is merged into alice",
bob <## "#team: you joined the group" "use @alice <message> to send messages",
"#team: you joined the group"
]
] ]
alice #> "#team hello" alice #> "#team hello"
bob <# "#team alice> hello" bob <# "#team alice> hello"
@@ -3998,7 +4002,7 @@ cc <##.. ls = do
unless prefix $ print ("expected to start from one of: " <> show ls, ", got: " <> l) unless prefix $ print ("expected to start from one of: " <> show ls, ", got: " <> l)
prefix `shouldBe` True prefix `shouldBe` True
data ConsoleResponse = ConsoleString String | WithTime String data ConsoleResponse = ConsoleString String | WithTime String | EndsWith String
deriving (Show) deriving (Show)
instance IsString ConsoleResponse where fromString = ConsoleString instance IsString ConsoleResponse where fromString = ConsoleString
@@ -4017,6 +4021,7 @@ getInAnyOrder f cc ls = do
expected l = \case expected l = \case
ConsoleString s -> l == s ConsoleString s -> l == s
WithTime s -> dropTime_ l == Just s WithTime s -> dropTime_ l == Just s
EndsWith s -> s `isSuffixOf` l
(<###) :: TestCC -> [ConsoleResponse] -> Expectation (<###) :: TestCC -> [ConsoleResponse] -> Expectation
(<###) = getInAnyOrder id (<###) = getInAnyOrder id