nuthatch/test/Nuthatch/Test/Product.hs

27 lines
950 B
Haskell
Raw Permalink Normal View History

module Nuthatch.Test.Product
( tests
) where
import Control.Concurrent (threadDelay)
import GHC.Clock (getMonotonicTimeNSec)
import Nuthatch.Browse (collectKeysBoundedWith)
import Nuthatch.S3 (ListPage (..))
import Test.Tasty (TestTree, testGroup)
import Test.Tasty.HUnit ((@?=), assertBool, testCase)
tests :: TestTree
tests = testGroup "product behavior"
[ testCase "search deadline cancels an in-flight listing" $ do
started <- getMonotonicTimeNSec
result <- collectKeysBoundedWith
getMonotonicTimeNSec
(\_ _ -> do
threadDelay 100000
pure (Right (ListPage [] [] Nothing False) :: Either () ListPage))
100
(started + 5000000)
finished <- getMonotonicTimeNSec
result @?= Right ([], True)
assertBool "listing returns inside the configured deadline margin"
(finished - started < 50000000)
]