chore(test): provide very "arbitrary" instance for ExamOccurrence
This commit is contained in:
parent
a9f432d6b0
commit
52678cddf4
@ -15,6 +15,17 @@ import Control.Applicative (ZipList(..))
|
|||||||
|
|
||||||
import Handler.Utils.Exam
|
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
|
newtype FixedHash = FixedHash Int
|
||||||
|
|
||||||
instance Hashable FixedHash where
|
instance Hashable FixedHash where
|
||||||
@ -38,12 +49,13 @@ spec = do
|
|||||||
rawUsers <- listOf1 $ Entity <$> arbitrary <*> arbitrary
|
rawUsers <- listOf1 $ Entity <$> arbitrary <*> arbitrary
|
||||||
-- user surnames anpassen, sodass interessante instanz
|
-- user surnames anpassen, sodass interessante instanz
|
||||||
let users = Map.fromList $ map (\Entity {entityKey, entityVal} -> (entityKey, (entityVal, Nothing))) rawUsers
|
let users = Map.fromList $ map (\Entity {entityKey, entityVal} -> (entityKey, (entityVal, Nothing))) rawUsers
|
||||||
--occurrences <- arbitrary :: Gen (Map ExamOccurrenceId Natural)
|
rawOccurrences <- listOf $ Entity <$> arbitrary <*> arbitrary
|
||||||
let occurrences = Map.empty :: Map ExamOccurrenceId Natural
|
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
|
let (maybeMapping, userMap) = examAutoOccurrence seed rule config occurrences users
|
||||||
pure $ ioProperty $ do
|
pure $ ioProperty $ do
|
||||||
print (length users, length occurrences)
|
|
||||||
shouldSatisfy rawUsers $ not . null
|
shouldSatisfy rawUsers $ not . null
|
||||||
|
shouldSatisfy occurrences $ not . null
|
||||||
where
|
where
|
||||||
-- name list copied from test/Database/Fill.hs
|
-- name list copied from test/Database/Fill.hs
|
||||||
surnames = [ "Smith", "Johnson", "Williams", "Brown"
|
surnames = [ "Smith", "Johnson", "Williams", "Brown"
|
||||||
|
|||||||
Reference in New Issue
Block a user