Revision 0b08c8bf

b/test/hs/Test/Ganeti/Query/Network.hs
62 62
  let net_keys = (Map.keys . fromContainer . groupNetworks) group
63 63
  in notElem uuid net_keys ==> isNothing (getGroupConnection uuid group)
64 64

  
65
-- | Check if getting the network's UUID from the config actually gets the
66
-- correct UUIDs.
67
prop_getNetworkUuid :: ConfigData -> Property
68
prop_getNetworkUuid cfg =
69
  let nets = (Map.elems . fromContainer . configNetworks) cfg
70
  in True ==? all
71
    (\n -> fromJust (getNetworkUuid cfg ((fromNonEmpty . networkName) n))
72
    == networkUuid n) nets
73

  
74
-- | Check if trying to get a UUID of a non-existing networks results in
75
-- 'Nothing'.
76
prop_getNetworkUuid_notFound :: ConfigData -> String -> Property
77
prop_getNetworkUuid_notFound cfg uuid =
78
  let net_keys = (Map.keys . fromContainer . configNetworks) cfg
79
  in notElem uuid net_keys ==> isNothing (getNetworkUuid cfg uuid)
80

  
81 65
-- | Checks whether actually connected instances are identified as such.
82 66
prop_instIsConnected :: ConfigData -> Property
83 67
prop_instIsConnected cfg =
......
99 83
        not (instIsConnected cfg network_uuid inst)
100 84

  
101 85
testSuite "Query_Network"
102
  [ 'prop_getNetworkUuid
103
  , 'prop_getNetworkUuid_notFound
104
  , 'prop_getGroupConnection
86
  [ 'prop_getGroupConnection
105 87
  , 'prop_getGroupConnection_notFound
106 88
  , 'prop_instIsConnected
107 89
  , 'prop_instIsConnected_notFound

Also available in: Unified diff