From 52678cddf4a8cdf3d97fb4aa495e3b69175fe5d3 Mon Sep 17 00:00:00 2001 From: Wolfgang Witt Date: Tue, 26 Jan 2021 17:45:23 +0100 Subject: [PATCH] chore(test): provide very "arbitrary" instance for ExamOccurrence --- test/Handler/Utils/ExamSpec.hs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/Handler/Utils/ExamSpec.hs b/test/Handler/Utils/ExamSpec.hs index 456984238..910c499ac 100644 --- a/test/Handler/Utils/ExamSpec.hs +++ b/test/Handler/Utils/ExamSpec.hs @@ -15,6 +15,17 @@ import Control.Applicative (ZipList(..)) import Handler.Utils.Exam + +instance Arbitrary ExamOccurrence where + arbitrary = ExamOccurrence <$> arbitrary -- examOccurrenceExam + <*> arbitrary -- examOccurrenceName + <*> arbitrary -- examOccurrenceRoom + <*> arbitrary -- examOccurrenceRoomHidden + <*> arbitrary -- examOccurrenceCapacity + <*> arbitrary -- examOccurrenceStart + <*> arbitrary -- examOccurrenceEnd + <*> arbitrary -- examOccurrenceDescription + newtype FixedHash = FixedHash Int instance Hashable FixedHash where @@ -38,12 +49,13 @@ spec = do rawUsers <- listOf1 $ Entity <$> arbitrary <*> arbitrary -- user surnames anpassen, sodass interessante instanz let users = Map.fromList $ map (\Entity {entityKey, entityVal} -> (entityKey, (entityVal, Nothing))) rawUsers - --occurrences <- arbitrary :: Gen (Map ExamOccurrenceId Natural) - let occurrences = Map.empty :: Map ExamOccurrenceId Natural + rawOccurrences <- listOf $ Entity <$> arbitrary <*> arbitrary + let occurrences = Map.fromList $ map (\Entity {entityKey, entityVal} -> (entityKey, examOccurrenceCapacity entityVal)) rawOccurrences + --let occurrences = Map.empty :: Map ExamOccurrenceId Natural let (maybeMapping, userMap) = examAutoOccurrence seed rule config occurrences users pure $ ioProperty $ do - print (length users, length occurrences) shouldSatisfy rawUsers $ not . null + shouldSatisfy occurrences $ not . null where -- name list copied from test/Database/Fill.hs surnames = [ "Smith", "Johnson", "Williams", "Brown"