diff options
Diffstat (limited to 'server/test')
| -rw-r--r-- | server/test/Spec.hs | 1 | ||||
| -rw-r--r-- | server/test/Thermoprint/Server/QueueSpec.hs | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/server/test/Spec.hs b/server/test/Spec.hs new file mode 100644 index 0000000..a824f8c --- /dev/null +++ b/server/test/Spec.hs | |||
| @@ -0,0 +1 @@ | |||
| {-# OPTIONS_GHC -F -pgmF hspec-discover #-} | |||
diff --git a/server/test/Thermoprint/Server/QueueSpec.hs b/server/test/Thermoprint/Server/QueueSpec.hs new file mode 100644 index 0000000..fd45e1b --- /dev/null +++ b/server/test/Thermoprint/Server/QueueSpec.hs | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | {-# LANGUAGE TypeSynonymInstances, FlexibleInstances, StandaloneDeriving #-} | ||
| 2 | |||
| 3 | module Thermoprint.Server.QueueSpec (spec) where | ||
| 4 | |||
| 5 | import Test.Hspec | ||
| 6 | import Test.Hspec.QuickCheck (prop) | ||
| 7 | |||
| 8 | import Thermoprint.Server.Queue | ||
| 9 | import Thermoprint.Server.Database | ||
| 10 | import Thermoprint.API hiding (JobId) | ||
| 11 | |||
| 12 | import Test.QuickCheck.Arbitrary | ||
| 13 | import Test.QuickCheck.Gen | ||
| 14 | import Test.QuickCheck.Modifiers | ||
| 15 | |||
| 16 | deriving instance (Eq PrintingError) | ||
| 17 | deriving instance (Eq Queue) | ||
| 18 | |||
| 19 | instance Arbitrary Queue where | ||
| 20 | arbitrary = Queue <$> arbitrary <*> arbitrary <*> arbitrary | ||
| 21 | |||
| 22 | instance Arbitrary QueueEntry where | ||
| 23 | arbitrary = QueueEntry <$> arbitrary <*> arbitrary | ||
| 24 | |||
| 25 | instance Arbitrary PrintingError where | ||
| 26 | arbitrary = oneof [ return UnknownError | ||
| 27 | ] | ||
| 28 | |||
| 29 | instance Arbitrary JobId where | ||
| 30 | arbitrary = castId . getNonNegative <$> (arbitrary :: Gen (NonNegative Integer)) | ||
| 31 | |||
| 32 | spec :: Spec | ||
| 33 | spec = do | ||
| 34 | prop "prop_zipper" $ \queue -> queue == toZipper (fromZipper queue) | ||
