aboutsummaryrefslogtreecommitdiff
path: root/server/test/Thermoprint/Server/QueueSpec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'server/test/Thermoprint/Server/QueueSpec.hs')
-rw-r--r--server/test/Thermoprint/Server/QueueSpec.hs34
1 files changed, 34 insertions, 0 deletions
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
3module Thermoprint.Server.QueueSpec (spec) where
4
5import Test.Hspec
6import Test.Hspec.QuickCheck (prop)
7
8import Thermoprint.Server.Queue
9import Thermoprint.Server.Database
10import Thermoprint.API hiding (JobId)
11
12import Test.QuickCheck.Arbitrary
13import Test.QuickCheck.Gen
14import Test.QuickCheck.Modifiers
15
16deriving instance (Eq PrintingError)
17deriving instance (Eq Queue)
18
19instance Arbitrary Queue where
20 arbitrary = Queue <$> arbitrary <*> arbitrary <*> arbitrary
21
22instance Arbitrary QueueEntry where
23 arbitrary = QueueEntry <$> arbitrary <*> arbitrary
24
25instance Arbitrary PrintingError where
26 arbitrary = oneof [ return UnknownError
27 ]
28
29instance Arbitrary JobId where
30 arbitrary = castId . getNonNegative <$> (arbitrary :: Gen (NonNegative Integer))
31
32spec :: Spec
33spec = do
34 prop "prop_zipper" $ \queue -> queue == toZipper (fromZipper queue)