minio-hs/test/Spec.hs
Aditya Manthramurthy ca3276cd87 Basic putObject is working:
- This is single PUT action - so only files up to 5GB.
- Buffers in memory because chunked singature is not yet implemented.
- fPutObject is simply wired to putObject (so does not yet work for
  multipart uploads
2017-02-13 16:03:42 +05:30

74 lines
2.3 KiB
Haskell

import Protolude
import Test.Tasty
import Test.Tasty.HUnit
-- import qualified System.IO as SIO
import Control.Monad.Trans.Resource (runResourceT)
-- import qualified Conduit as C
-- import Data.Conduit.Binary
import Network.Minio
-- import Network.Minio.S3API
import XmlTests
main :: IO ()
main = defaultMain tests
-- main = putStrLn ("Test suite not yet implemented" :: Text)
tests :: TestTree
tests = testGroup "Tests" [properties, unitTests]
properties :: TestTree
properties = testGroup "Properties" [] -- [scProps, qcProps]
-- scProps = testGroup "(checked by SmallCheck)"
-- [ SC.testProperty "sort == sort . reverse" $
-- \list -> sort (list :: [Int]) == sort (reverse list)
-- , SC.testProperty "Fermat's little theorem" $
-- \x -> ((x :: Integer)^7 - x) `mod` 7 == 0
-- -- the following property does not hold
-- , SC.testProperty "Fermat's last theorem" $
-- \x y z n ->
-- (n :: Integer) >= 3 SC.==> x^n + y^n /= (z^n :: Integer)
-- ]
-- qcProps = testGroup "(checked by QuickCheck)"
-- [ QC.testProperty "sort == sort . reverse" $
-- \list -> sort (list :: [Int]) == sort (reverse list)
-- , QC.testProperty "Fermat's little theorem" $
-- \x -> ((x :: Integer)^7 - x) `mod` 7 == 0
-- -- the following property does not hold
-- , QC.testProperty "Fermat's last theorem" $
-- \x y z n ->
-- (n :: Integer) >= 3 QC.==> x^n + y^n /= (z^n :: Integer)
-- ]
unitTests :: TestTree
unitTests = testGroup "Unit tests"
[ testCaseSteps "Check getService returns without exception" $ \step -> do
step "Preparing..."
mc <- connect defaultConnectInfo
step "Running test.."
ret <- runResourceT $ runMinio mc $ getService
isRight ret @? ("getService failure => " ++ show ret)
, testCaseSteps "Simple putObject works" $ \step -> do
step "Preparing..."
mc <- connect defaultConnectInfo
step "Running test.."
ret <- runResourceT $ runMinio mc $
fPutObject "testbucket" "lsb-release" "/etc/lsb-release"
-- h <- SIO.openBinaryFile "/etc/lsb-release" SIO.ReadMode
-- ret <- runResourceT $ runMinio mc $
-- putObject "testbucket" "lsb-release" [] 0 105 h
isRight ret @? ("putObject failure => " ++ show ret)
, testCase "Test mkCreateBucketConfig." testMkCreateBucketConfig
]