Revision 4d0e8b1d
b/test/hs/Test/Ganeti/TestCommon.hs | ||
---|---|---|
51 | 51 |
, genSetHelper |
52 | 52 |
, genSet |
53 | 53 |
, genListSet |
54 |
, genAndRestArguments |
|
54 | 55 |
, genIPv4Address |
55 | 56 |
, genIPv4Network |
56 | 57 |
, genIp6Addr |
... | ... | |
73 | 74 |
import Control.Monad |
74 | 75 |
import Data.Attoparsec.Text (Parser, parseOnly) |
75 | 76 |
import Data.List |
77 |
import qualified Data.Map as M |
|
76 | 78 |
import Data.Text (pack) |
77 | 79 |
import Data.Word |
78 | 80 |
import qualified Data.Set as Set |
... | ... | |
290 | 292 |
-> Gen (BasicTypes.ListSet a) |
291 | 293 |
genListSet is = BasicTypes.ListSet <$> genSet is |
292 | 294 |
|
295 |
-- | Generate an arbitrary element of and AndRestArguments field. |
|
296 |
genAndRestArguments :: Gen (M.Map String J.JSValue) |
|
297 |
genAndRestArguments = do |
|
298 |
n <- choose (0::Int, 10) |
|
299 |
let oneParam _ = do |
|
300 |
name <- choose (15 ::Int, 25) |
|
301 |
>>= flip vectorOf (elements tagChar) |
|
302 |
intvalue <- arbitrary |
|
303 |
value <- oneof [ J.JSString . J.toJSString <$> genName |
|
304 |
, return $ J.showJSON (intvalue :: Int) |
|
305 |
] |
|
306 |
return (name, value) |
|
307 |
M.fromList `liftM` mapM oneParam [1..n] |
|
308 |
|
|
293 | 309 |
-- | Generate an arbitrary IPv4 address in textual form. |
294 | 310 |
genIPv4 :: Gen String |
295 | 311 |
genIPv4 = do |
Also available in: Unified diff