From 566e69e835b6b16ad16a9dcff1fe2aaaca7db6b5 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 19 May 2021 21:34:59 +0200 Subject: [PATCH] chore: fix tests --- test/Model/Types/WorkflowSpec.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/Model/Types/WorkflowSpec.hs b/test/Model/Types/WorkflowSpec.hs index 263e66610..da81543a3 100644 --- a/test/Model/Types/WorkflowSpec.hs +++ b/test/Model/Types/WorkflowSpec.hs @@ -16,7 +16,7 @@ import qualified Data.Set as Set import qualified Data.Aeson as Aeson -import Control.Lens.Extras (is) +import Utils.Lens import Utils.I18n @@ -119,8 +119,17 @@ instance (Arbitrary fileid, Arbitrary userid, Ord fileid, Typeable userid, Typea instance (Arbitrary payload, IsWorkflowFieldPayload' fileid userid payload) => Arbitrary (WorkflowFieldPayload fileid userid payload) where arbitrary = review _WorkflowFieldPayload <$> arbitrary -instance (Arbitrary termid, Arbitrary schoolid, Arbitrary courseid) => Arbitrary (WorkflowScope termid schoolid courseid) where - arbitrary = genericArbitrary +instance (Arbitrary termid, Arbitrary courseid) => Arbitrary (WorkflowScope termid SchoolShorthand courseid) where + arbitrary = oneof + [ pure WSGlobal + , WSTerm <$> arbitrary + , WSSchool <$> arbitrarySchoolShorthand + , WSTermSchool <$> arbitrary <*> arbitrarySchoolShorthand + , WSCourse <$> arbitrary + ] + where arbitrarySchoolShorthand = CI.mk . pack <$> (fmap getPrintableString arbitrary `suchThat` (not . null)) +instance (Arbitrary termid, Arbitrary courseid) => Arbitrary (WorkflowScope termid SchoolId courseid) where + arbitrary = over _wisSchool SchoolKey <$> arbitrary instance (CoArbitrary termid, CoArbitrary schoolid, CoArbitrary courseid) => CoArbitrary (WorkflowScope termid schoolid courseid) instance (Function termid, Function schoolid, Function courseid) => Function (WorkflowScope termid schoolid courseid)