33{-# OPTIONS_GHC -fno-warn-orphans #-}
44module Test.Mismi.S3.Core.Arbitrary where
55
6- import Data.Text as T
6+ import qualified Data.List as L
7+ import qualified Data.Text as T
78
8- import Disorder.Corpus
9+ import Disorder.Corpus ( simpsons , southpark )
910
1011import Mismi.S3.Core.Data
1112
1213import P
1314
14- import Test.QuickCheck
15+ import Test.QuickCheck (Arbitrary (.. ), Gen )
16+ import qualified Test.QuickCheck as QC
1517import Test.QuickCheck.Instances ()
1618
19+ import System.FilePath (FilePath )
1720
1821instance Arbitrary WriteMode where
19- arbitrary = elements [Fail , Overwrite ]
22+ arbitrary = QC. elements [Fail , Overwrite ]
2023
2124instance Arbitrary Bucket where
22- arbitrary = Bucket <$> elements southpark
25+ arbitrary = Bucket <$> QC. elements southpark
2326
2427instance Arbitrary Address where
25- arbitrary = frequency [
28+ arbitrary = QC. frequency [
2629 (9 , Address <$> arbitrary <*> arbitrary)
2730 , (1 , flip Address (Key " " ) <$> arbitrary)
2831 ]
@@ -32,8 +35,17 @@ instance Arbitrary Key where
3235 -- Unfortunately unicode characters aren't supported in the Haskell AWS library
3336 -- https://github.com/ambiata/vee/issues/7
3437 arbitrary =
35- let genPath = elements [" happy" , " sad" , " ." , " :" , " -" ]
38+ let genPath = QC. elements [" happy" , " sad" , " ." , " :" , " -" ]
3639 path = do
37- sep <- elements [" -" , " =" , " #" , " " ]
38- T. take 256 . T. intercalate " /" <$> listOf1 (T. intercalate sep <$> listOf1 genPath)
39- in (Key . append " tests/" ) <$> path
40+ sep <- QC. elements [" -" , " =" , " #" , " " ]
41+ T. take 256 . T. intercalate " /" <$> QC. listOf1 (T. intercalate sep <$> QC. listOf1 genPath)
42+ in (Key . T. append " tests/" ) <$> path
43+
44+
45+ fileNameSizePairs :: Int -> Gen [(FilePath , Int64 )]
46+ fileNameSizePairs len = do
47+ names <- QC. vectorOf len $ QC. elements simpsons
48+ lengths <- QC. vectorOf len $ QC. choose (1 , 1000000000 )
49+ pure $ L. zipWith3 zipper names [(0 :: Int ) .. ] lengths
50+ where
51+ zipper n i l = (n <> show i, l)
0 commit comments