add hasPrivContentFrom
This commit is contained in:
parent
86052a5310
commit
932cb7c5d6
|
@ -18,18 +18,26 @@ f `hasContent` newcontent = fileProperty ("replace " ++ f)
|
||||||
-- The file's permissions are preserved if the file already existed.
|
-- The file's permissions are preserved if the file already existed.
|
||||||
-- Otherwise, they're set to 600.
|
-- Otherwise, they're set to 600.
|
||||||
hasPrivContent :: IsContext c => FilePath -> c -> Property
|
hasPrivContent :: IsContext c => FilePath -> c -> Property
|
||||||
hasPrivContent = hasPrivContent' writeFileProtected
|
hasPrivContent f = hasPrivContentFrom (PrivDataSourceFile (PrivFile f) f) f
|
||||||
|
|
||||||
|
-- | Like hasPrivContent, but allows specifying a source
|
||||||
|
-- for PrivData, rather than using PrivDataSourceFile.
|
||||||
|
hasPrivContentFrom :: (IsContext c, IsPrivDataSource s) => s -> FilePath -> c -> Property
|
||||||
|
hasPrivContentFrom = hasPrivContent' writeFileProtected
|
||||||
|
|
||||||
-- | Leaves the file at its default or current mode,
|
-- | Leaves the file at its default or current mode,
|
||||||
-- allowing "private" data to be read.
|
-- allowing "private" data to be read.
|
||||||
--
|
--
|
||||||
-- Use with caution!
|
-- Use with caution!
|
||||||
hasPrivContentExposed :: IsContext c => FilePath -> c -> Property
|
hasPrivContentExposed :: IsContext c => FilePath -> c -> Property
|
||||||
hasPrivContentExposed = hasPrivContent' writeFile
|
hasPrivContentExposed f = hasPrivContentExposedFrom (PrivDataSourceFile (PrivFile f) f) f
|
||||||
|
|
||||||
hasPrivContent' :: IsContext c => (String -> FilePath -> IO ()) -> FilePath -> c -> Property
|
hasPrivContentExposedFrom :: (IsContext c, IsPrivDataSource s) => s -> FilePath -> c -> Property
|
||||||
hasPrivContent' writer f context =
|
hasPrivContentExposedFrom = hasPrivContent' writeFile
|
||||||
withPrivData (PrivDataSourceFile (PrivFile f) f) context $ \getcontent ->
|
|
||||||
|
hasPrivContent' :: (IsContext c, IsPrivDataSource s) => (String -> FilePath -> IO ()) -> s -> FilePath -> c -> Property
|
||||||
|
hasPrivContent' writer source f context =
|
||||||
|
withPrivData source context $ \getcontent ->
|
||||||
property desc $ getcontent $ \privcontent ->
|
property desc $ getcontent $ \privcontent ->
|
||||||
ensureProperty $ fileProperty' writer desc
|
ensureProperty $ fileProperty' writer desc
|
||||||
(\_oldcontent -> lines privcontent) f
|
(\_oldcontent -> lines privcontent) f
|
||||||
|
|
Loading…
Reference in New Issue