File: ConnectionSpec.hs

package info (click to toggle)
haskell-http-client 0.7.17-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 528 kB
  • sloc: haskell: 4,029; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 978 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Network.HTTP.Client.ConnectionSpec where

import Network.HTTP.Client (strippedHostName)
import Test.Hspec

spec :: Spec
spec = do
    describe "strippedHostName" $ do
        it "passes along a normal domain name" $ do
            strippedHostName "example.com" `shouldBe` "example.com"
        it "passes along an IPv4 address" $ do
            strippedHostName "127.0.0.1" `shouldBe` "127.0.0.1"
        it "strips brackets of an IPv4 address" $ do
            strippedHostName "[::1]" `shouldBe` "::1"
            strippedHostName "[::127.0.0.1]" `shouldBe` "::127.0.0.1"

        describe "pathological cases" $ do
            -- just need to handle these gracefully, it's unclear
            -- what the result should be
            it "doesn't touch future ip address formats" $ do
                strippedHostName "[v2.huh]" `shouldBe` "[v2.huh]"
            it "doesn't strip trailing stuff" $ do
                strippedHostName "[::1]foo" `shouldBe` "[::1]foo"