On Wed, Sep 25, 2013 at 12:11 PM, Jose A. Lopes <[email protected]>wrote:

> Add 'HUnit' test for 'buildVersion'.
>
> Signed-off-by: Jose A. Lopes <[email protected]>
> ---
>  Makefile.am                      |  1 +
>  test/hs/Test/Ganeti/Constants.hs | 75
> ++++++++++++++++++++++++++++++++++++++++
>  test/hs/htest.hs                 |  2 ++
>  3 files changed, 78 insertions(+)
>  create mode 100644 test/hs/Test/Ganeti/Constants.hs
>
> diff --git a/Makefile.am b/Makefile.am
> index af7c184..e610179 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -719,6 +719,7 @@ HS_TEST_SRCS = \
>         test/hs/Test/Ganeti/Common.hs \
>         test/hs/Test/Ganeti/Confd/Types.hs \
>         test/hs/Test/Ganeti/Confd/Utils.hs \
> +       test/hs/Test/Ganeti/Constants.hs \
>         test/hs/Test/Ganeti/Daemon.hs \
>         test/hs/Test/Ganeti/Errors.hs \
>         test/hs/Test/Ganeti/HTools/Backend/Simu.hs \
> diff --git a/test/hs/Test/Ganeti/Constants.hs
> b/test/hs/Test/Ganeti/Constants.hs
> new file mode 100644
> index 0000000..f696b9e
> --- /dev/null
> +++ b/test/hs/Test/Ganeti/Constants.hs
> @@ -0,0 +1,75 @@
> +{-# LANGUAGE TemplateHaskell #-}
> +{-| Unittests for constants
> +
> +-}
> +
> +{-
> +
> +Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
>

Only 2013 required for new files (unless you copied stuff from somewhere
else).


> +
> +This program is free software; you can redistribute it and/or modify
> +it under the terms of the GNU General Public License as published by
> +the Free Software Foundation; either version 2 of the License, or
> +(at your option) any later version.
> +
> +This program is distributed in the hope that it will be useful, but
> +WITHOUT ANY WARRANTY; without even the implied warranty of
> +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +General Public License for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with this program; if not, write to the Free Software
> +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +02110-1301, USA.
> +
> +-}
> +
> +module Test.Ganeti.Constants (testConstants) where
> +
> +import Test.HUnit (Assertion)
> +import qualified Test.HUnit as HUnit
> +
> +import qualified Ganeti.Constants as Constants
> +import qualified Ganeti.ConstantUtils as ConstantUtils
> +import qualified Test.Ganeti.TestHelper as TestHelper
> +
> +case_buildVersion :: Assertion
> +case_buildVersion = do
> +  HUnit.assertBool "Config major lower-bound violation"
> +                   (Constants.configMajor >= 0)
> +  HUnit.assertBool "Config major upper-bound violation"
> +                   (Constants.configMajor <= 99)
> +  HUnit.assertBool "Config minor lower-bound violation"
> +                   (Constants.configMinor >= 0)
> +  HUnit.assertBool "Config minor upper-bound violation"
> +                   (Constants.configMinor <= 99)
> +  HUnit.assertBool "Config revision lower-bound violation"
> +                   (Constants.configRevision >= 0)
> +  HUnit.assertBool "Config revision upper-bound violation"
> +                   (Constants.configRevision <= 9999)
> +  HUnit.assertBool "Config version lower-bound violation"
> +                   (Constants.configVersion >= 0)
> +  HUnit.assertBool "Config version upper-bound violation"
> +                   (Constants.configVersion <= 99999999)
> +  HUnit.assertEqual "Build version"
> +                    (ConstantUtils.buildVersion 0 0 0) 0
> +  HUnit.assertEqual "Build version"
> +                    (ConstantUtils.buildVersion 10 10 1010) 10101010
> +  HUnit.assertEqual "Build version"
> +                    (ConstantUtils.buildVersion 12 34 5678) 12345678
> +  HUnit.assertEqual "Build version"
> +                    (ConstantUtils.buildVersion 99 99 9999) 99999999
> +  HUnit.assertEqual "Build version"
> +                    (ConstantUtils.buildVersion
> +                     Constants.configMajor
> +                     Constants.configMinor
> +                     Constants.configRevision) Constants.configVersion
> +  HUnit.assertEqual "Build version"
> +                    (ConstantUtils.buildVersion
> +                     Constants.configMajor
> +                     Constants.configMinor
> +                     Constants.configRevision) Constants.protocolVersion
> +
> +TestHelper.testSuite "Constants"
> +  [ 'case_buildVersion
> +  ]
> diff --git a/test/hs/htest.hs b/test/hs/htest.hs
> index 9c417bb..ca0e4fb 100644
> --- a/test/hs/htest.hs
> +++ b/test/hs/htest.hs
> @@ -34,6 +34,7 @@ import Test.Ganeti.TestImports ()
>  import Test.Ganeti.Attoparsec
>  import Test.Ganeti.BasicTypes
>  import Test.Ganeti.Common
> +import Test.Ganeti.Constants
>  import Test.Ganeti.Confd.Utils
>  import Test.Ganeti.Confd.Types
>  import Test.Ganeti.Daemon
> @@ -90,6 +91,7 @@ allTests =
>    [ testBasicTypes
>    , testAttoparsec
>    , testCommon
> +  , testConstants
>    , testConfd_Types
>    , testConfd_Utils
>    , testDaemon
> --
> 1.8.4
>
>
Rest LGTM, thanks.

-- 
Thomas Thrainer | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to