Statistics
| Branch: | Tag: | Revision:

root / test / hs / Test / Ganeti / Ssconf.hs @ 1f87d93d

History | View | Annotate | Download (1.6 kB)

1
{-# LANGUAGE TemplateHaskell #-}
2
{-# OPTIONS_GHC -fno-warn-orphans #-}
3

    
4
{-| Unittests for ganeti-htools.
5

    
6
-}
7

    
8
{-
9

    
10
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
11

    
12
This program is free software; you can redistribute it and/or modify
13
it under the terms of the GNU General Public License as published by
14
the Free Software Foundation; either version 2 of the License, or
15
(at your option) any later version.
16

    
17
This program is distributed in the hope that it will be useful, but
18
WITHOUT ANY WARRANTY; without even the implied warranty of
19
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
General Public License for more details.
21

    
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
02110-1301, USA.
26

    
27
-}
28

    
29
module Test.Ganeti.Ssconf (testSsconf) where
30

    
31
import Test.QuickCheck
32

    
33
import Data.List
34
import qualified Data.Map as M
35

    
36
import Test.Ganeti.TestHelper
37
import Test.Ganeti.TestCommon
38

    
39
import qualified Ganeti.Ssconf as Ssconf
40

    
41
-- * Ssconf tests
42

    
43
$(genArbitrary ''Ssconf.SSKey)
44

    
45
instance Arbitrary Ssconf.SSConf where
46
  arbitrary = fmap (Ssconf.SSConf . M.fromList) arbitrary
47

    
48
-- * Reading SSConf
49

    
50
prop_filename :: Ssconf.SSKey -> Property
51
prop_filename key =
52
  printTestCase "Key doesn't start with correct prefix" $
53
    Ssconf.sSFilePrefix `isPrefixOf` Ssconf.keyToFilename "" key
54

    
55
-- * Creating and writing SSConf
56

    
57
-- | Verify that for SSConf we have readJSON . showJSON = Ok.
58
prop_ReadShow :: Ssconf.SSConf -> Property
59
prop_ReadShow = testSerialisation
60

    
61
testSuite "Ssconf"
62
  [ 'prop_filename
63
  , 'prop_ReadShow
64
  ]