diff --git a/minio-hs.cabal b/minio-hs.cabal index 69d7000..ce6b23b 100644 --- a/minio-hs.cabal +++ b/minio-hs.cabal @@ -72,19 +72,54 @@ executable minio-hs-exe test-suite minio-hs-test type: exitcode-stdio-1.0 - hs-source-dirs: test + hs-source-dirs: test, src main-is: Spec.hs build-depends: base , minio-hs , protolude >= 0.1.6 && < 0.2 + , bytestring + , case-insensitive + , conduit + , conduit-combinators + , conduit-extra + , containers + , cryptonite + , errors + , filepath + , http-client + , http-conduit + , http-types + , memory , resourcet , tasty - , tasty-smallcheck - , tasty-quickcheck , tasty-hunit + , tasty-quickcheck + , tasty-smallcheck + , text + , time + , transformers + , transformers-base + , xml-conduit ghc-options: -Wall -threaded -rtsopts -with-rtsopts=-N default-language: Haskell2010 - default-extensions: OverloadedStrings, NoImplicitPrelude + default-extensions: FlexibleContexts + , FlexibleInstances + , OverloadedStrings + , NoImplicitPrelude + , MultiParamTypeClasses + , MultiWayIf + other-modules: Lib.Prelude + , Network.Minio + , Network.Minio.API + , Network.Minio.Data + , Network.Minio.Data.ByteString + , Network.Minio.Data.Crypto + , Network.Minio.Data.Time + , Network.Minio.S3API + , Network.Minio.Sign.V4 + , Network.Minio.XmlGenerator + , Network.Minio.XmlParser + source-repository head type: git diff --git a/src/Network/Minio/Data.hs b/src/Network/Minio/Data.hs index f53c356..acad056 100644 --- a/src/Network/Minio/Data.hs +++ b/src/Network/Minio/Data.hs @@ -2,7 +2,6 @@ module Network.Minio.Data ( ConnectInfo(..) , RequestInfo(..) --- , ResponseInfo(..) , MinioConn(..) , Bucket , Object diff --git a/src/Network/Minio/S3API.hs b/src/Network/Minio/S3API.hs index d0733a6..244049d 100644 --- a/src/Network/Minio/S3API.hs +++ b/src/Network/Minio/S3API.hs @@ -45,7 +45,7 @@ putBucket :: Bucket -> Location -> Minio () putBucket bucket location = do void $ executeRequest $ requestInfo HT.methodPut (Just bucket) Nothing [] [] $ - Just $ mkCreateBucketConfig bucket location + Just $ mkCreateBucketConfig location deleteBucket :: Bucket -> Minio () deleteBucket bucket = do diff --git a/src/Network/Minio/XmlGenerator.hs b/src/Network/Minio/XmlGenerator.hs index c3890e7..7a69efa 100644 --- a/src/Network/Minio/XmlGenerator.hs +++ b/src/Network/Minio/XmlGenerator.hs @@ -10,11 +10,13 @@ import qualified Data.Map as M import Network.Minio.Data -mkCreateBucketConfig :: Bucket -> Location -> ByteString -mkCreateBucketConfig bucket location = LBS.toStrict $ renderLBS def bucketConfig + +mkCreateBucketConfig :: Location -> ByteString +mkCreateBucketConfig location = LBS.toStrict $ renderLBS def bucketConfig where - root = Element (s3Name "CreateBucketConfiguration") M.empty - [ NodeElement $ Element "LocationConstraint" M.empty + s3Element n = Element (s3Name n) M.empty + root = s3Element "CreateBucketConfiguration" + [ NodeElement $ s3Element "LocationConstraint" [ NodeContent location] ] bucketConfig = Document (Prologue [] Nothing []) root [] diff --git a/test/Spec.hs b/test/Spec.hs index 0c90534..7f43899 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,13 +1,12 @@ import Protolude import Test.Tasty -import Test.Tasty.SmallCheck as SC -import Test.Tasty.QuickCheck as QC import Test.Tasty.HUnit import Control.Monad.Trans.Resource (runResourceT) import Network.Minio +import Network.Minio.XmlGenerator main :: IO () main = defaultMain tests @@ -41,11 +40,9 @@ properties = testGroup "Properties" [] -- [scProps, qcProps] -- (n :: Integer) >= 3 QC.==> x^n + y^n /= (z^n :: Integer) -- ] +unitTests :: TestTree unitTests = testGroup "Unit tests" - [ testCase "List comparison (different length)" $ - [1, 2, 3] `compare` [1,2] @?= GT, - - testCaseSteps "Check getService returns without exception" $ \step -> do + [ testCaseSteps "Check getService returns without exception" $ \step -> do step "Preparing..." mc <- connect defaultConnectInfo @@ -54,4 +51,14 @@ unitTests = testGroup "Unit tests" ret <- runResourceT $ runMinio mc $ getService isRight ret @? ("getService failure => " ++ show ret) + , testCase "Test mkCreateBucketConfig." testMkCreateBucketConfig ] + +usEastBucketConfig :: ByteString +usEastBucketConfig = "\ + \EU\ + \" + +testMkCreateBucketConfig :: Assertion +testMkCreateBucketConfig = do + assertEqual "CreateBucketConfiguration xml should match: " usEastBucketConfig $ mkCreateBucketConfig "EU"