Commit 63571096 authored by Petr Pudlak's avatar Petr Pudlak

Add tests for Ganeti.THH.Types

In particular, test (de)serialization of "OneTuple".
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 1263a102
......@@ -143,7 +143,8 @@ HS_DIRS = \
test/hs/Test/Ganeti/HTools/Backend \
test/hs/Test/Ganeti/Hypervisor \
test/hs/Test/Ganeti/Hypervisor/Xen \
test/hs/Test/Ganeti/Query
test/hs/Test/Ganeti/Query \
test/hs/Test/Ganeti/THH
# Haskell directories without the roots (src, test/hs)
HS_DIRS_NOROOT = $(filter-out src,$(filter-out test/hs,$(HS_DIRS)))
......@@ -801,6 +802,7 @@ HS_TEST_SRCS = \
test/hs/Test/Ganeti/Storage/Drbd/Types.hs \
test/hs/Test/Ganeti/Storage/Lvm/LVParser.hs \
test/hs/Test/Ganeti/THH.hs \
test/hs/Test/Ganeti/THH/Types.hs \
test/hs/Test/Ganeti/TestCommon.hs \
test/hs/Test/Ganeti/TestHTools.hs \
test/hs/Test/Ganeti/TestHelper.hs \
......
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-| Unittests for 'Ganeti.THH.Types'.
-}
{-
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.THH.Types
( testTHH_Types
) where
import Test.QuickCheck as QuickCheck hiding (Result)
import qualified Text.JSON as J
import Test.Ganeti.TestCommon
import Test.Ganeti.TestHelper
import Ganeti.THH.Types
{-# ANN module "HLint: ignore Use camelCase" #-}
-- * Instances
instance Arbitrary a => Arbitrary (OneTuple a) where
arbitrary = fmap OneTuple arbitrary
-- * Properties
-- | Tests OneTuple serialisation.
prop_OneTuple_serialisation :: OneTuple String -> Property
prop_OneTuple_serialisation = testSerialisation
-- | Tests OneTuple doesn't deserialize wrong input.
prop_OneTuple_deserialisationFail :: Property
prop_OneTuple_deserialisationFail =
conjoin . map (testDeserialisationFail (OneTuple "")) $
[ J.JSArray []
, J.JSArray [J.showJSON "a", J.showJSON "b"]
, J.JSArray [J.showJSON (1 :: Int)]
]
-- * Test suite
testSuite "THH_Types"
[ 'prop_OneTuple_serialisation
, 'prop_OneTuple_deserialisationFail
]
......@@ -74,6 +74,7 @@ import Test.Ganeti.Storage.Drbd.Parser
import Test.Ganeti.Storage.Drbd.Types
import Test.Ganeti.Storage.Lvm.LVParser
import Test.Ganeti.THH
import Test.Ganeti.THH.Types
import Test.Ganeti.Types
import Test.Ganeti.Utils
......@@ -135,6 +136,7 @@ allTests =
, testSsconf
, testStorage_Lvm_LVParser
, testTHH
, testTHH_Types
, testTypes
, testUtils
]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment