27 lines
928 B
Haskell
27 lines
928 B
Haskell
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)))
|
|
100
|
|
(started + 5000000)
|
|
finished <- getMonotonicTimeNSec
|
|
result @?= Right ([], True)
|
|
assertBool "listing returns inside the configured deadline margin"
|
|
(finished - started < 50000000)
|
|
]
|