Created
October 30, 2017 17:53
-
-
Save josejuan/a17a8f9670c544e863a67b6146bc624d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frequencyCounterSpec _ctCode _cCode = | |
describe "FrequencyCounter actions" $ do | |
let rq action auth = action $ CounterReq (CounterTypeReq auth _ctCode) _cCode | |
speed milliseconds times msg sat = do | |
it ("Running " ++ show times ++ " times every " ++ show milliseconds ++ " mS should " ++ msg) $ rq $ \r -> do | |
forM_ [1..times] $ \_ -> do | |
void $ cli $ counterPost r 1 | |
liftIO $ threadDelay (1000 * milliseconds) | |
rs <- cli $ counterPost r 1 | |
rs `shouldSatisfy` sat | |
forM_ [1..3] $ \_ -> do | |
speed 1000 5 "works" isRight | |
speed 1 5 "fail" isLeft | |
it "Recovering time..." $ rq $ \r -> do | |
liftIO $ threadDelay (1000 * 5000) | |
1 `shouldBe` 1 | |
{- | |
... | |
Add -3 is not granted | |
Counter value should be -2 | |
Add 2 is granted | |
Counter value should be 0 | |
Creating the `bar` counter type | |
FrequencyCounter actions | |
Running 5 times every 1000 mS should works | |
Running 5 times every 1 mS should fail | |
Recovering time... | |
Running 5 times every 1000 mS should works | |
Running 5 times every 1 mS should fail | |
Recovering time... | |
Running 5 times every 1000 mS should works | |
Running 5 times every 1 mS should fail | |
Recovering time... | |
The list should contains two elements, the `foo` and `bar` counter types | |
Reading the `bar` counter type must contains one counter | |
... | |
-} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment