{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, StandaloneDeriving #-} module Thermoprint.Server.QueueSpec (spec) where import Test.Hspec import Test.Hspec.QuickCheck (prop) import Thermoprint.Server.Queue import Thermoprint.Server.Database import Thermoprint.API hiding (JobId) import Test.QuickCheck.Arbitrary import Test.QuickCheck.Gen import Test.QuickCheck.Modifiers deriving instance (Eq PrintingError) deriving instance (Eq Queue) instance Arbitrary Queue where arbitrary = Queue <$> arbitrary <*> arbitrary <*> arbitrary instance Arbitrary QueueEntry where arbitrary = QueueEntry <$> arbitrary <*> arbitrary instance Arbitrary PrintingError where arbitrary = oneof [ return (IOError "dummy") ] instance Arbitrary JobId where arbitrary = castId . getNonNegative <$> (arbitrary :: Gen (NonNegative Integer)) spec :: Spec spec = do describe "queue morphisms" $ do prop "are inverse" $ \queue -> queue == toZipper (fromZipper queue)