Revision 285d04a1

b/Makefile.am
719 719
	test/hs/Test/Ganeti/Common.hs \
720 720
	test/hs/Test/Ganeti/Confd/Types.hs \
721 721
	test/hs/Test/Ganeti/Confd/Utils.hs \
722
	test/hs/Test/Ganeti/Constants.hs \
722 723
	test/hs/Test/Ganeti/Daemon.hs \
723 724
	test/hs/Test/Ganeti/Errors.hs \
724 725
	test/hs/Test/Ganeti/HTools/Backend/Simu.hs \
b/test/hs/Test/Ganeti/Constants.hs
1
{-# LANGUAGE TemplateHaskell #-}
2
{-| Unittests for constants
3

  
4
-}
5

  
6
{-
7

  
8
Copyright (C) 2013 Google Inc.
9

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

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

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

  
25
-}
26

  
27
module Test.Ganeti.Constants (testConstants) where
28

  
29
import Test.HUnit (Assertion)
30
import qualified Test.HUnit as HUnit
31

  
32
import qualified Ganeti.Constants as Constants
33
import qualified Ganeti.ConstantUtils as ConstantUtils
34
import qualified Test.Ganeti.TestHelper as TestHelper
35

  
36
case_buildVersion :: Assertion
37
case_buildVersion = do
38
  HUnit.assertBool "Config major lower-bound violation"
39
                   (Constants.configMajor >= 0)
40
  HUnit.assertBool "Config major upper-bound violation"
41
                   (Constants.configMajor <= 99)
42
  HUnit.assertBool "Config minor lower-bound violation"
43
                   (Constants.configMinor >= 0)
44
  HUnit.assertBool "Config minor upper-bound violation"
45
                   (Constants.configMinor <= 99)
46
  HUnit.assertBool "Config revision lower-bound violation"
47
                   (Constants.configRevision >= 0)
48
  HUnit.assertBool "Config revision upper-bound violation"
49
                   (Constants.configRevision <= 9999)
50
  HUnit.assertBool "Config version lower-bound violation"
51
                   (Constants.configVersion >= 0)
52
  HUnit.assertBool "Config version upper-bound violation"
53
                   (Constants.configVersion <= 99999999)
54
  HUnit.assertEqual "Build version"
55
                    (ConstantUtils.buildVersion 0 0 0) 0
56
  HUnit.assertEqual "Build version"
57
                    (ConstantUtils.buildVersion 10 10 1010) 10101010
58
  HUnit.assertEqual "Build version"
59
                    (ConstantUtils.buildVersion 12 34 5678) 12345678
60
  HUnit.assertEqual "Build version"
61
                    (ConstantUtils.buildVersion 99 99 9999) 99999999
62
  HUnit.assertEqual "Build version"
63
                    (ConstantUtils.buildVersion
64
                     Constants.configMajor
65
                     Constants.configMinor
66
                     Constants.configRevision) Constants.configVersion
67
  HUnit.assertEqual "Build version"
68
                    (ConstantUtils.buildVersion
69
                     Constants.configMajor
70
                     Constants.configMinor
71
                     Constants.configRevision) Constants.protocolVersion
72

  
73
TestHelper.testSuite "Constants"
74
  [ 'case_buildVersion
75
  ]
b/test/hs/htest.hs
34 34
import Test.Ganeti.Attoparsec
35 35
import Test.Ganeti.BasicTypes
36 36
import Test.Ganeti.Common
37
import Test.Ganeti.Constants
37 38
import Test.Ganeti.Confd.Utils
38 39
import Test.Ganeti.Confd.Types
39 40
import Test.Ganeti.Daemon
......
90 91
  [ testBasicTypes
91 92
  , testAttoparsec
92 93
  , testCommon
94
  , testConstants
93 95
  , testConfd_Types
94 96
  , testConfd_Utils
95 97
  , testDaemon

Also available in: Unified diff