tweet-hs-1.0.0.1: test/Spec.hs
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString as BS
import Test.Hspec
import Test.Hspec.Megaparsec
import Web.Tweet.Parser.FastParser
import Web.Tweet.Parser
import Web.Tweet.Sign
import Data.Monoid
import Text.Megaparsec
import System.Environment
import Test.QuickCheck
main :: IO ()
main = hspec $ do
describe "aeson parser" $ do
file <- runIO $ BS.readFile "test/data"
parallel $ it "parses sample tweets wrong" $ do
fastParse "" `shouldBe` Left "Error in $: not enough input"
describe "handrolled parser" $ do
file <- runIO $ BS.readFile "test/data"
parallel $ it "parses sample tweets right" $ do
parse parseTweet "test suite" `shouldSucceedOn` file
describe "config parser" $ do
config <- runIO $ (<> "/.cred") <$> getEnv "HOME"
configToml <- runIO $ (<> "/.cred.toml") <$> getEnv "HOME"
parallel $ it "parses a config file the same way with the toml parser" $
((==) <$> mkConfigToml configToml <*> mkConfig config) >>= (`shouldBe` True)