-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
101 additions
and
41 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{-# LANGUAGE LambdaCase, OverloadedStrings #-} | ||
|
||
module Main (main) where | ||
|
||
import Data.ISO3166_CountryCodes (CountryCode(US)) | ||
import Network.HTTP.Client (newManager) | ||
import Network.HTTP.Client (defaultManagerSettings) | ||
import Network.HTTP.Client.TLS (tlsManagerSettings) | ||
import Network.HTTP.Types.Status (unauthorized401) | ||
import Servant.Client (ServantError(..)) | ||
import Test.Hspec | ||
import Ziptastic.Client | ||
|
||
apiKey :: ApiKey | ||
apiKey = "fake-key" | ||
|
||
main :: IO () | ||
main = do | ||
insecureManager <- newManager defaultManagerSettings | ||
secureManager <- newManager tlsManagerSettings | ||
hspec $ | ||
describe "http client machinery" $ do | ||
it "can make requests with secure manager" $ do | ||
response <- forwardGeocode apiKey secureManager US "48867" | ||
response `shouldSatisfy` \case | ||
Left (FailureResponse{responseStatus=status}) -> status == unauthorized401 | ||
_ -> False | ||
|
||
it "can make requests with insecure manager" $ do | ||
response <- forwardGeocode apiKey insecureManager US "48867" | ||
response `shouldSatisfy` \case | ||
Left (FailureResponse{responseStatus=status}) -> status == unauthorized401 | ||
_ -> False | ||
|
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
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
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
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
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