Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from SEEK-Org/fix-tests-on-windows
Browse files Browse the repository at this point in the history
Fixed tests on Windows
  • Loading branch information
askoufis committed Dec 14, 2016
2 parents 326c7f5 + 02681bb commit c49cc2d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto

# Retain LF endings for text files in data because they're used in hashing
# tests and the tests will fail if the git rewrites the line endings
data/**/*.txt text=auto eol=lf
1 change: 1 addition & 0 deletions evaporate.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ test-suite evaporate-test
, amazonka-s3
, either
, exceptions
, filepath
, fgl
, hspec
, hspec-core
Expand Down
20 changes: 11 additions & 9 deletions test/ZipSpec.hs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
module ZipSpec (spec, main) where

import Control.Monad.Trans.Resource (runResourceT)
import Data.Text (pack)
import Network.AWS.S3.Types (BucketName(..))
import System.FilePath ( (</>) )
import Test.Hspec (describe , context , it , hspec , Spec)
import Test.Hspec.Expectations.Pretty (shouldBe, shouldThrow)

import StackParameters (BucketFiles(..))
import Types (FileOrFolderDoesNotExist(..))
import Zip(inlineZips, writeZip, getPathInArchive)
import Zip (inlineZips, writeZip, getPathInArchive)

main :: IO ()
main = hspec spec
Expand All @@ -22,9 +24,9 @@ spec = describe "ZipSpec" $ do
, _isZipped = True
, _paths = [
("file1.txt", "newName")
,("path/to/file.txt", "path/to/file.txt")
,(pack $ "path" </> "to" </> "file.txt", pack $ "path" </> "to" </> "file.txt")
,("folder", "folder")
,("path/to/folder2", "path/to/folder2")
,(pack $ "path" </> "to" </> "folder2", pack $ "path" </> "to" </> "folder2")
]
}
let output = BucketFiles
Expand All @@ -33,15 +35,15 @@ spec = describe "ZipSpec" $ do
, _isZipped = True
, _paths = [
("file1.txt.zip", "newName.zip")
,("file.txt.zip", "path/to/file.txt.zip")
,("file.txt.zip", pack $ "path" </> "to" </> "file.txt.zip")
,("folder.zip", "folder.zip")
,("folder2.zip", "path/to/folder2.zip")
,("folder2.zip", pack $ "path" </> "to" </> "folder2.zip")
]
}
inlineZips bucketFiles `shouldBe` output

it "should throw if a file or folder can't be found" $ do
let path = "this/file/does/not/exit.blah"
let path = pack $ "this" </> "file" </> "does" </> "not" </> "exit.blah"
(runResourceT . writeZip) path `shouldThrow` (== FileOrFolderDoesNotExist path)

context "archive paths" $ do
Expand All @@ -52,15 +54,15 @@ spec = describe "ZipSpec" $ do

it "file in folder in empty root path" $ do
let rootPath = ""
let path = "folder/file.txt"
let path = "folder" </> "file.txt"
getPathInArchive rootPath path `shouldBe` "folder"

it "file in folder root path" $ do
let rootPath = "folder"
let path = "folder/file.txt"
let path = "folder" </> "file.txt"
getPathInArchive rootPath path `shouldBe` ""

it "file in folder in folder root path" $ do
let rootPath = "folder"
let path = "folder/folder2/file.txt"
let path = "folder" </> "folder2" </> "file.txt"
getPathInArchive rootPath path `shouldBe` "folder2"

0 comments on commit c49cc2d

Please sign in to comment.