1 {-# LANGUAGE TemplateHaskell #-}
2 {-# OPTIONS_GHC -fno-warn-orphans #-}
4 {-| Unittests for ganeti-htools.
10 Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
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.
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.
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
29 module Test.Ganeti.Objects (testObjects) where
31 import qualified Data.Map as Map
32 import Test.QuickCheck
34 import Test.Ganeti.TestHelper
35 import qualified Ganeti.Objects as Objects
37 -- | Tests that fillDict behaves correctly
38 prop_Objects_fillDict :: [(Int, Int)] -> [(Int, Int)] -> Property
39 prop_Objects_fillDict defaults custom =
40 let d_map = Map.fromList defaults
41 d_keys = map fst defaults
42 c_map = Map.fromList custom
43 c_keys = map fst custom
44 in printTestCase "Empty custom filling"
45 (Objects.fillDict d_map Map.empty [] == d_map) .&&.
46 printTestCase "Empty defaults filling"
47 (Objects.fillDict Map.empty c_map [] == c_map) .&&.
48 printTestCase "Delete all keys"
49 (Objects.fillDict d_map c_map (d_keys++c_keys) == Map.empty)
52 [ 'prop_Objects_fillDict