-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainSpec.hs
30 lines (23 loc) · 923 Bytes
/
MainSpec.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{-# LANGUAGE OverloadedStrings #-}
module Maintainability.MTL.MainSpec where
import Data.Function ((&))
import Data.Functor.Identity (runIdentity)
import Data.Time.Clock.POSIX (posixSecondsToUTCTime)
import Test.Hspec
import Maintainability.MTL.Main
import Maintainability.MTL.Stubs
spec :: Spec
spec = describe "main" $ do
let startTime = posixSecondsToUTCTime 0.0
endTime = posixSecondsToUTCTime 0.000123
((), logMessages) = runIdentity $ mainLogic
& runArgumentsT ["sample.txt"]
& runFileSystemT [("sample.txt", "Alyssa")]
& runLoggerT
& runPresetClockT [startTime, endTime]
it "prints two log messages" $
length logMessages `shouldBe` 2
it "prints a greeting as the first message" $
(logMessages !! 0) `shouldBe` "Hello, Alyssa!"
it "prints the elapsed time in milliseconds as the second message" $
(logMessages !! 1) `shouldBe` "123 microseconds"