-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hackage creds are read-only (fixes #2159)
- Loading branch information
Showing
3 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module Stack.UploadSpec (spec) where | ||
|
||
import RIO | ||
import RIO.Directory | ||
import RIO.FilePath ((</>)) | ||
import Stack.Upload | ||
import Test.Hspec | ||
import System.Permissions (osIsWindows) | ||
import System.PosixCompat.Files (getFileStatus, fileMode) | ||
import Data.Bits ((.&.)) | ||
|
||
spec :: Spec | ||
spec = do | ||
it "writeFilePrivate" $ example $ withSystemTempDirectory "writeFilePrivate" $ \dir -> replicateM_ 2 $ do | ||
let fp = dir </> "filename" | ||
contents :: IsString s => s | ||
contents = "These are the contents" | ||
writeFilePrivate fp contents | ||
actual <- readFileBinary fp | ||
actual `shouldBe` contents | ||
perms <- getPermissions fp | ||
perms `shouldBe` setOwnerReadable True emptyPermissions | ||
|
||
unless osIsWindows $ do | ||
status <- getFileStatus fp | ||
(fileMode status .&. 0o777) `shouldBe` 0o400 |