root / htest / Test / Ganeti / Jobs.hs @ b88fcdd0
History | View | Annotate | Download (1.9 kB)
1 | 2d87bd0a | Iustin Pop | {-# LANGUAGE TemplateHaskell #-} |
---|---|---|---|
2 | 2d87bd0a | Iustin Pop | {-# OPTIONS_GHC -fno-warn-orphans #-} |
3 | 2d87bd0a | Iustin Pop | |
4 | 2d87bd0a | Iustin Pop | {-| Unittests for ganeti-htools. |
5 | 2d87bd0a | Iustin Pop | |
6 | 2d87bd0a | Iustin Pop | -} |
7 | 2d87bd0a | Iustin Pop | |
8 | 2d87bd0a | Iustin Pop | {- |
9 | 2d87bd0a | Iustin Pop | |
10 | 2d87bd0a | Iustin Pop | Copyright (C) 2009, 2010, 2011, 2012 Google Inc. |
11 | 2d87bd0a | Iustin Pop | |
12 | 2d87bd0a | Iustin Pop | This program is free software; you can redistribute it and/or modify |
13 | 2d87bd0a | Iustin Pop | it under the terms of the GNU General Public License as published by |
14 | 2d87bd0a | Iustin Pop | the Free Software Foundation; either version 2 of the License, or |
15 | 2d87bd0a | Iustin Pop | (at your option) any later version. |
16 | 2d87bd0a | Iustin Pop | |
17 | 2d87bd0a | Iustin Pop | This program is distributed in the hope that it will be useful, but |
18 | 2d87bd0a | Iustin Pop | WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | 2d87bd0a | Iustin Pop | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 | 2d87bd0a | Iustin Pop | General Public License for more details. |
21 | 2d87bd0a | Iustin Pop | |
22 | 2d87bd0a | Iustin Pop | You should have received a copy of the GNU General Public License |
23 | 2d87bd0a | Iustin Pop | along with this program; if not, write to the Free Software |
24 | 2d87bd0a | Iustin Pop | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
25 | 2d87bd0a | Iustin Pop | 02110-1301, USA. |
26 | 2d87bd0a | Iustin Pop | |
27 | 2d87bd0a | Iustin Pop | -} |
28 | 2d87bd0a | Iustin Pop | |
29 | 2d87bd0a | Iustin Pop | module Test.Ganeti.Jobs (testJobs) where |
30 | 2d87bd0a | Iustin Pop | |
31 | 2d87bd0a | Iustin Pop | import Test.QuickCheck |
32 | 2d87bd0a | Iustin Pop | |
33 | 2d87bd0a | Iustin Pop | import qualified Text.JSON as J |
34 | 2d87bd0a | Iustin Pop | |
35 | 2d87bd0a | Iustin Pop | import Test.Ganeti.TestHelper |
36 | 2d87bd0a | Iustin Pop | import Test.Ganeti.TestCommon |
37 | 2d87bd0a | Iustin Pop | |
38 | 2d87bd0a | Iustin Pop | import qualified Ganeti.Jobs as Jobs |
39 | 2d87bd0a | Iustin Pop | |
40 | 2d87bd0a | Iustin Pop | -- * Arbitrary instances |
41 | 2d87bd0a | Iustin Pop | |
42 | 2d87bd0a | Iustin Pop | instance Arbitrary Jobs.OpStatus where |
43 | 2d87bd0a | Iustin Pop | arbitrary = elements [minBound..maxBound] |
44 | 2d87bd0a | Iustin Pop | |
45 | 2d87bd0a | Iustin Pop | instance Arbitrary Jobs.JobStatus where |
46 | 2d87bd0a | Iustin Pop | arbitrary = elements [minBound..maxBound] |
47 | 2d87bd0a | Iustin Pop | |
48 | 2d87bd0a | Iustin Pop | -- * Test cases |
49 | 2d87bd0a | Iustin Pop | |
50 | 2d87bd0a | Iustin Pop | -- | Check that (queued) job\/opcode status serialization is idempotent. |
51 | 2d87bd0a | Iustin Pop | prop_Jobs_OpStatus_serialization :: Jobs.OpStatus -> Property |
52 | 2d87bd0a | Iustin Pop | prop_Jobs_OpStatus_serialization os = |
53 | 2d87bd0a | Iustin Pop | case J.readJSON (J.showJSON os) of |
54 | 2d87bd0a | Iustin Pop | J.Error e -> failTest $ "Cannot deserialise: " ++ e |
55 | 2d87bd0a | Iustin Pop | J.Ok os' -> os ==? os' |
56 | 2d87bd0a | Iustin Pop | |
57 | 2d87bd0a | Iustin Pop | prop_Jobs_JobStatus_serialization :: Jobs.JobStatus -> Property |
58 | 2d87bd0a | Iustin Pop | prop_Jobs_JobStatus_serialization js = |
59 | 2d87bd0a | Iustin Pop | case J.readJSON (J.showJSON js) of |
60 | 2d87bd0a | Iustin Pop | J.Error e -> failTest $ "Cannot deserialise: " ++ e |
61 | 2d87bd0a | Iustin Pop | J.Ok js' -> js ==? js' |
62 | 2d87bd0a | Iustin Pop | |
63 | 2d87bd0a | Iustin Pop | testSuite "Jobs" |
64 | 2d87bd0a | Iustin Pop | [ 'prop_Jobs_OpStatus_serialization |
65 | 2d87bd0a | Iustin Pop | , 'prop_Jobs_JobStatus_serialization |
66 | 2d87bd0a | Iustin Pop | ] |