pinboard 0.9.12.1 → 0.9.12.2
raw patch · 4 files changed
+28/−30 lines, 4 filesdep ~vector
Dependency ranges changed: vector
Files
- changelog.md +4/−0
- pinboard.cabal +4/−4
- src/Pinboard/Client.hs +3/−2
- tests/Test.hs +17/−24
changelog.md view
@@ -1,3 +1,7 @@+__v0.9.12.2++vector bounds+ __v0.9.12.1 bug fixes
pinboard.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.14.1.+-- This file has been generated from package.yaml by hpack version 0.15.0. -- -- see: https://github.com/sol/hpack name: pinboard-version: 0.9.12.1+version: 0.9.12.2 synopsis: Access to the Pinboard API description: . The Pinboard API is a way to interact programatically with@@ -47,7 +47,7 @@ , http-client-tls >=0.3.0 && <0.4 , text >=0.11 && <1.3 , time >=1.5 && <1.7- , vector >=0.10.9 && <0.12+ , vector >=0.10.9 && <0.13 , network >=2.6.2 && <2.7 , profunctors >=5 , random >=1.1@@ -72,7 +72,7 @@ main-is: Test.hs hs-source-dirs: tests- ghc-options: -Wall -fno-warn-orphans -fno-warn-orphans+ ghc-options: -Wall -fno-warn-orphans build-depends: base >=4.6 && <5.0 , transformers >=0.4.0.0
src/Pinboard/Client.hs view
@@ -105,6 +105,7 @@ unsafePerformIO $ newIORef (UTCTime (ModifiedJulianDay 0) 0) , doThreadDelay = Pinboard.Client.requestThreadDelay }+{-# NOINLINE defaultPinboardConfig #-} -------------------------------------------------------------------------------- -- | Execute computations in the Pinboard monad@@ -183,7 +184,7 @@ -------------------------------------------------------------------------------- --- | delays the thread if the time since the previous request exceeds the configured maxRequestRateMills +-- | delays the thread, if the time since the previous request is less than the configured maxRequestRateMills requestThreadDelay :: PinboardConfig -> IO () requestThreadDelay cfg@PinboardConfig {..} = do currentTime <- getCurrentTime@@ -214,7 +215,7 @@ return $ setRequestIgnoreStatus $ req- { requestHeaders = [("User-Agent", "pinboard.hs/0.9.12.1")]+ { requestHeaders = [("User-Agent", "pinboard.hs/0.9.12.2")] } --------------------------------------------------------------------------------
tests/Test.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE PartialTypeSignatures #-} module Main where @@ -19,7 +20,7 @@ hspec $ do prop "UTCTime" $ \(x :: UTCTime) ->- (readNoteTime . showNoteTime) x == (return x :: Maybe UTCTime)+ (readNoteTime . showNoteTime) x == Just x describe "JSON instances" $ do propJSONEq (Proxy :: Proxy UTCTime) propJSONEq (Proxy :: Proxy Post)@@ -31,26 +32,18 @@ propJSONEq (Proxy :: Proxy Suggested) propJSONApproxEq (Proxy :: Proxy PostDates) describe "decodeJSONResponse: handle parse failures" $- do it "malformed object parses as ParseFailure" $- let noteJson = "FAIL"- in case decodeJSONResponse noteJson of- Left PinboardError {..} -> errorType == ParseFailure- Right Note {..} -> False- it "malformed field parses as ParseFailure" $- let noteJson =- "{\"length\":0,\"hash\":\"\",\"text_FAIL\":\"\",\"updated_at\":\"1864-05-09 13:50:53\",\"created_at\":\"1864-05-09 18:21:35\",\"id\":\"\",\"title\":\"\"}"- in case decodeJSONResponse noteJson of- Left PinboardError {..} -> errorType == ParseFailure- Right Note {..} -> False- it "malformed value parses as ParseFailure" $- let noteJson =- "{\"length\":FAIL,\"hash\":\"\",\"text\":\"\",\"updated_at\":\"1864-05-09 13:50:53\",\"created_at\":\"1864-05-09 18:21:35\",\"id\":\"\",\"title\":\"\"}"- in case decodeJSONResponse noteJson of- Left PinboardError {..} -> errorType == ParseFailure- Right Note {..} -> False- it "malformed time parses as ParseFailure" $- let noteJson =- "{\"length\":0,\"hash\":\"\",\"text\":\"\",\"updated_at\":\"FAIL-05-09 13:50:53\",\"created_at\":\"1864-05-09 18:21:35\",\"id\":\"\",\"title\":\"\"}"- in case decodeJSONResponse noteJson of- Left PinboardError {..} -> errorType == ParseFailure- Right Note {..} -> False+ let expectNoteParseFailure json =+ case (decodeJSONResponse json :: Either PinboardError Note) of+ Left e -> errorType e == ParseFailure+ _ -> False+ in do it "malformed object parses as ParseFailure" $+ expectNoteParseFailure "FAIL"+ it "malformed field parses as ParseFailure" $+ expectNoteParseFailure+ "{\"length\":0,\"hash\":\"\",\"text_FAIL\":\"\",\"updated_at\":\"1864-05-09 13:50:53\",\"created_at\":\"1864-05-09 18:21:35\",\"id\":\"\",\"title\":\"\"}"+ it "malformed value parses as ParseFailure" $+ expectNoteParseFailure+ "{\"length\":FAIL,\"hash\":\"\",\"text\":\"\",\"updated_at\":\"1864-05-09 13:50:53\",\"created_at\":\"1864-05-09 18:21:35\",\"id\":\"\",\"title\":\"\"}"+ it "malformed time parses as ParseFailure" $+ expectNoteParseFailure+ "{\"length\":0,\"hash\":\"\",\"text\":\"\",\"updated_at\":\"FAIL-05-09 13:50:53\",\"created_at\":\"1864-05-09 18:21:35\",\"id\":\"\",\"title\":\"\"}"