quickcheck property for parsing of content identifier logs
This commit is contained in:
parent
7c25cc7715
commit
936aee6a60
7 changed files with 40 additions and 16 deletions
|
@ -45,6 +45,7 @@ import Utility.Metered
|
|||
import Git.Types (RemoteName)
|
||||
import Utility.SafeCommand
|
||||
import Utility.Url
|
||||
import Utility.QuickCheck
|
||||
|
||||
type RemoteConfigKey = String
|
||||
|
||||
|
@ -246,7 +247,7 @@ data ExportActions a = ExportActions
|
|||
{- An identifier for content stored on a remote. It should be reasonably
|
||||
- short since it is stored in the git-annex branch. -}
|
||||
newtype ContentIdentifier = ContentIdentifier S.ByteString
|
||||
deriving (Eq, Ord, Show)
|
||||
deriving (Eq, Ord, Show, Arbitrary)
|
||||
|
||||
{- Some remotes may support importing a history of versions of content that
|
||||
- is stored in them. This is equivilant to a git commit history. -}
|
||||
|
@ -256,6 +257,7 @@ data ContentHistory t
|
|||
{ contentHistoryCurrent :: t
|
||||
, contentHistoryPrev :: [ContentHistory t]
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
data ImportActions a = ImportActions
|
||||
-- Finds the current set of files that are stored in the remote,
|
||||
|
|
|
@ -14,10 +14,12 @@ import qualified Data.Map as M
|
|||
import qualified Data.UUID as U
|
||||
import Data.Maybe
|
||||
import Data.String
|
||||
import Data.Char
|
||||
import Data.ByteString.Builder
|
||||
import qualified Data.Semigroup as Sem
|
||||
|
||||
import Utility.FileSystemEncoding
|
||||
import Utility.QuickCheck
|
||||
import qualified Utility.SimpleProtocol as Proto
|
||||
|
||||
-- A UUID is either an arbitrary opaque string, or UUID info may be missing.
|
||||
|
@ -81,3 +83,11 @@ type UUIDDescMap = M.Map UUID UUIDDesc
|
|||
instance Proto.Serializable UUID where
|
||||
serialize = fromUUID
|
||||
deserialize = Just . toUUID
|
||||
|
||||
instance Arbitrary UUID where
|
||||
arbitrary = frequency [(1, return NoUUID), (3, UUID <$> arb)]
|
||||
where
|
||||
-- Avoid non-ascii because fully arbitrary
|
||||
-- strings may not be encoded using the filesystem
|
||||
-- encoding, which is normally applied to all input.
|
||||
arb = encodeBS <$> arbitrary `suchThat` all isAscii
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue