[Pkg-ganeti-devel] [ganeti] 10/165: Factor out Bool -> {"y", "n"} in test

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Tue Aug 11 13:53:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to branch master
in repository ganeti.

commit a37c4230176bec2c60bc0d4f3693792a8ba0c989
Author: Aaron Karper <akarper at google.com>
Date:   Thu Jan 22 10:59:49 2015 +0100

    Factor out Bool -> {"y", "n"} in test
    
    To avoid duplication and typos, boolean flags are converted using a
    helper function.
    
    Signed-off-by: Aaron Karper <akarper at google.com>
    Reviewed-by: Klaus Aehlig <aehlig at google.com>
---
 test/hs/Test/Ganeti/HTools/Backend/Text.hs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/test/hs/Test/Ganeti/HTools/Backend/Text.hs b/test/hs/Test/Ganeti/HTools/Backend/Text.hs
index fba46d0..a6bf0b4 100644
--- a/test/hs/Test/Ganeti/HTools/Backend/Text.hs
+++ b/test/hs/Test/Ganeti/HTools/Backend/Text.hs
@@ -67,6 +67,10 @@ import qualified Ganeti.Utils as Utils
 
 -- * Instance text loader tests
 
+toYN :: Bool -> String
+toYN True = "Y"
+toYN False = "N"
+
 prop_Load_Instance :: String -> Int -> Int -> Int -> Types.InstanceStatus
                    -> NonEmptyList Char -> String
                    -> NonNegative Int -> NonNegative Int -> Bool
@@ -85,7 +89,7 @@ prop_Load_Instance name mem dsk vcpus status
               else [(pnode, pdx), (snode, sdx)]
       nl = Map.fromList ndx
       tags = ""
-      sbal = if autobal then "Y" else "N"
+      sbal = toYN autobal
       sdt = Types.diskTemplateToRaw dt
       inst = Text.loadInst nl
              [name, mem_s, dsk_s, vcpus_s, status_s,
@@ -141,9 +145,7 @@ prop_Load_Node name tm nm fm td fd tc fo =
       td_s = conv td
       fd_s = conv fd
       tc_s = conv tc
-      fo_s = if fo
-               then "Y"
-               else "N"
+      fo_s = toYN fo
       any_broken = any (< 0) [tm, nm, fm, td, fd, tc]
       gid = Group.uuid defGroup
   in case Text.loadNode defGroupAssoc

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ganeti/ganeti.git



More information about the Pkg-ganeti-devel mailing list