In particular, test serialization of IPv4Reservation, which is used on the Python part as well.
Signed-off-by: Petr Pudlak <[email protected]> --- Makefile.am | 6 ++-- test/hs/Test/Ganeti/WConfd/TempRes.hs | 58 +++++++++++++++++++++++++++++++++++ test/hs/htest.hs | 2 ++ 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 test/hs/Test/Ganeti/WConfd/TempRes.hs diff --git a/Makefile.am b/Makefile.am index cfc4cab..a482603 100644 --- a/Makefile.am +++ b/Makefile.am @@ -160,7 +160,8 @@ HS_DIRS = \ test/hs/Test/Ganeti/Objects \ test/hs/Test/Ganeti/Query \ test/hs/Test/Ganeti/THH \ - test/hs/Test/Ganeti/Utils + test/hs/Test/Ganeti/Utils \ + test/hs/Test/Ganeti/WConfd # Haskell directories without the roots (src, test/hs) HS_DIRS_NOROOT = $(filter-out src,$(filter-out test/hs,$(HS_DIRS))) @@ -942,7 +943,8 @@ HS_TEST_SRCS = \ test/hs/Test/Ganeti/TestHelper.hs \ test/hs/Test/Ganeti/Types.hs \ test/hs/Test/Ganeti/Utils.hs \ - test/hs/Test/Ganeti/Utils/Statistics.hs + test/hs/Test/Ganeti/Utils/Statistics.hs \ + test/hs/Test/Ganeti/WConfd/TempRes.hs HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS) diff --git a/test/hs/Test/Ganeti/WConfd/TempRes.hs b/test/hs/Test/Ganeti/WConfd/TempRes.hs new file mode 100644 index 0000000..2999b4f --- /dev/null +++ b/test/hs/Test/Ganeti/WConfd/TempRes.hs @@ -0,0 +1,58 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} + +{-| Tests for temporary configuration resources allocation + +-} + +{- + +Copyright (C) 2014 Google Inc. + +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.WConfd.TempRes (testWConfd_TempRes) where + +import Control.Applicative + +import Test.QuickCheck + +import Test.Ganeti.Objects () +import Test.Ganeti.TestCommon +import Test.Ganeti.TestHelper + +import Ganeti.WConfd.TempRes + +-- * Instances + +instance Arbitrary IPv4ResAction where + arbitrary = elements [minBound..maxBound] + +instance Arbitrary IPv4Reservation where + arbitrary = IPv4Res <$> arbitrary <*> arbitrary <*> arbitrary + +-- * Tests + +prop_IPv4Reservation_serialisation :: IPv4Reservation -> Property +prop_IPv4Reservation_serialisation = testSerialisation + +-- * The tests combined + +testSuite "WConfd/TempRes" + [ 'prop_IPv4Reservation_serialisation + ] diff --git a/test/hs/htest.hs b/test/hs/htest.hs index a50ca98..230ae8d 100644 --- a/test/hs/htest.hs +++ b/test/hs/htest.hs @@ -82,6 +82,7 @@ import Test.Ganeti.THH.Types import Test.Ganeti.Types import Test.Ganeti.Utils import Test.Ganeti.Utils.Statistics +import Test.Ganeti.WConfd.TempRes -- | Our default test options, overring the built-in test-framework -- ones (but not the supplied command line parameters). @@ -149,6 +150,7 @@ allTests = , testTypes , testUtils , testUtils_Statistics + , testWConfd_TempRes ] -- | Main function. Note we don't use defaultMain since we want to -- 2.0.0.526.g5318336
