Revision e5a29b6c
b/Makefile.am | ||
---|---|---|
60 | 60 |
htools/Ganeti/HTools \ |
61 | 61 |
htools/Ganeti/HTools/Program \ |
62 | 62 |
htools/Ganeti/Query \ |
63 |
htest |
|
63 |
htest \ |
|
64 |
htest/Test \ |
|
65 |
htest/Test/Ganeti |
|
64 | 66 |
|
65 | 67 |
DIRS = \ |
66 | 68 |
autotools \ |
... | ... | |
374 | 376 |
--exclude Ganeti.THH \ |
375 | 377 |
--exclude Ganeti.HTools.QC \ |
376 | 378 |
--exclude Ganeti.HTools.Version \ |
377 |
--exclude Test.Ganeti.TestHelper |
|
379 |
--exclude Test.Ganeti.TestHelper \ |
|
380 |
$(patsubst htools.%,--exclude Test.%,$(subst /,.,$(patsubst %.hs,%, $(filter-out htest/%,$(HS_LIB_SRCS))))) |
|
378 | 381 |
|
379 | 382 |
HS_LIB_SRCS = \ |
380 | 383 |
htools/Ganeti/HTools/CLI.hs \ |
... | ... | |
426 | 429 |
htools/Ganeti/Runtime.hs \ |
427 | 430 |
htools/Ganeti/Ssconf.hs \ |
428 | 431 |
htools/Ganeti/THH.hs \ |
429 |
htest/Test/Ganeti/TestHelper.hs |
|
432 |
htest/Test/Ganeti/TestHelper.hs \ |
|
433 |
htest/Test/Ganeti/Objects.hs |
|
430 | 434 |
|
431 | 435 |
|
432 | 436 |
HS_BUILT_SRCS = htools/Ganeti/HTools/Version.hs htools/Ganeti/Constants.hs |
b/htest/Test/Ganeti/Objects.hs | ||
---|---|---|
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.Objects (testObjects) where |
|
30 |
|
|
31 |
import qualified Data.Map as Map |
|
32 |
import Test.QuickCheck |
|
33 |
|
|
34 |
import Test.Ganeti.TestHelper |
|
35 |
import qualified Ganeti.Objects as Objects |
|
36 |
|
|
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) |
|
50 |
|
|
51 |
testSuite "Objects" |
|
52 |
[ 'prop_Objects_fillDict |
|
53 |
] |
b/htest/test.hs | ||
---|---|---|
30 | 30 |
import System.Environment (getArgs) |
31 | 31 |
|
32 | 32 |
import Ganeti.HTools.QC |
33 |
import Test.Ganeti.Objects |
|
33 | 34 |
|
34 | 35 |
-- | Our default test options, overring the built-in test-framework |
35 | 36 |
-- ones. |
b/htools/Ganeti/HTools/QC.hs | ||
---|---|---|
51 | 51 |
, testRpc |
52 | 52 |
, testQlang |
53 | 53 |
, testConfd |
54 |
, testObjects |
|
55 | 54 |
) where |
56 | 55 |
|
57 | 56 |
import qualified Test.HUnit as HUnit |
... | ... | |
2173 | 2172 |
[ 'prop_Confd_req_sign |
2174 | 2173 |
, 'prop_Confd_bad_key |
2175 | 2174 |
] |
2176 |
|
|
2177 |
-- * Objects tests |
|
2178 |
|
|
2179 |
-- | Tests that fillDict behaves correctly |
|
2180 |
prop_Objects_fillDict :: [(Int, Int)] -> [(Int, Int)] -> Property |
|
2181 |
prop_Objects_fillDict defaults custom = |
|
2182 |
let d_map = Map.fromList defaults |
|
2183 |
d_keys = map fst defaults |
|
2184 |
c_map = Map.fromList custom |
|
2185 |
c_keys = map fst custom |
|
2186 |
in printTestCase "Empty custom filling" |
|
2187 |
(Objects.fillDict d_map Map.empty [] == d_map) .&&. |
|
2188 |
printTestCase "Empty defaults filling" |
|
2189 |
(Objects.fillDict Map.empty c_map [] == c_map) .&&. |
|
2190 |
printTestCase "Delete all keys" |
|
2191 |
(Objects.fillDict d_map c_map (d_keys++c_keys) == Map.empty) |
|
2192 |
|
|
2193 |
testSuite "Objects" |
|
2194 |
[ 'prop_Objects_fillDict |
|
2195 |
] |
Also available in: Unified diff