From 88b91108650ba2978858b4a57032ad79101d9f8a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 20 May 2019 14:23:15 +0200 Subject: [PATCH] Make test produce fewer false negatives --- test/Handler/Utils/SubmissionSpec.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/Handler/Utils/SubmissionSpec.hs b/test/Handler/Utils/SubmissionSpec.hs index 4caeba5fa..763c40b14 100644 --- a/test/Handler/Utils/SubmissionSpec.hs +++ b/test/Handler/Utils/SubmissionSpec.hs @@ -163,7 +163,7 @@ spec = withApp . describe "Submission distribution" $ do distributionExample (return [ (n, loads) | n <- ns' ]) (\subs corrs -> do - tutSubmissions <- liftIO $ getRandomR (1,500) + tutSubmissions <- liftIO $ getRandomR (1,50) subs' <- liftIO $ shuffleM subs forM_ (take tutSubmissions subs') $ \(Entity subId Submission{..}) -> do Entity _ SheetCorrector{..} <- liftIO $ uniform corrs @@ -179,10 +179,8 @@ spec = withApp . describe "Submission distribution" $ do (\result -> do let countResult = Map.map Set.size result countResult' = Map.mapKeysWith (+) (fmap $ \SheetCorrector{..} -> (fromSqlKey sheetCorrectorUser, byProportion sheetCorrectorLoad)) countResult - tutSubIds' <- liftIO $ readTVarIO tutSubIds - countResult' `shouldNotSatisfy` Map.member Nothing - countResult' `shouldSatisfy` all (\(Just (corr, prop), subsSet) -> fromIntegral subsSet <= max (50 * prop) (maybe 0 (fromIntegral . Set.size) $ tutSubIds' !? toSqlKey corr)) . Map.toList + countResult' `shouldSatisfy` all (\(Just (corr, prop), subsSet) -> fromIntegral subsSet == 50 * prop) . Map.toList -- -- Does not currently work, because `User`s are reused within `distributionExample`, so submissions end up having more associated course-tutors, because the same user might be a member of a tutorial created for another submission --