heroku 0.1.1.1 → 0.1.2
raw patch · 3 files changed
+36/−10 lines, 3 filesdep +hspec
Dependencies added: hspec
Files
- Web/Heroku/Internal.hs +9/−8
- heroku.cabal +10/−2
- test.hs +17/−0
Web/Heroku/Internal.hs view
@@ -27,17 +27,18 @@ Nothing -> invalid Just a -> (a, uriPath uri) (user,password) = userAndPassword auth- in [- (pack "user", user)- -- tail not safe, but should be there on Heroku- ,(pack "password", Data.Text.tail password)- ,(pack "host", pack $ uriRegName auth)- -- Heroku should use default port- -- ,(pack "port", pack $ uriPort auth)+ in [ (pack "user", user)+ -- tail not safe, but should be there on Heroku+ , (pack "password", Data.Text.tail password)+ , (pack "host", pack $ uriRegName auth)+ , (pack "port", pack $ removeColon $ uriPort auth) -- tail not safe but path should always be there- ,(pack "dbname", pack $ Prelude.tail $ path)+ , (pack "dbname", pack $ Prelude.tail $ path) ] where+ removeColon (':':port) = port+ removeColon port = port+ -- init is not safe, but should be there on Heroku userAndPassword :: URIAuth -> (Text, Text) userAndPassword = (breakOn $ pack ":") . pack . Prelude.init . uriUserInfo
heroku.cabal view
@@ -1,5 +1,5 @@ Name: heroku-Version: 0.1.1.1+Version: 0.1.2 Synopsis: helpers for deploying to Heroku Description: currently just a parser for DATABASE_URL Homepage: https://github.com/gregwebs/haskell-heroku@@ -10,7 +10,7 @@ Category: Web Build-type: Simple -Cabal-version: >=1.2+Cabal-version: >= 1.8 Library@@ -23,3 +23,11 @@ Build-depends: base >= 4 && < 5 , text , network++Test-Suite test+ Type: exitcode-stdio-1.0+ Main-Is: test.hs+ Build-depends: base >= 4 && < 5+ , text+ , network+ , hspec
+ test.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE OverloadedStrings #-}+module Main where++import Web.Heroku+import Test.Hspec++main :: IO ()+main = hspec $+ describe "parseDatabaseUrl" $+ it "extracts individual items" $+ parseDatabaseUrl "postgres://db:pass@ec2-1-1-1-1.compute-1.amazonaws.com:1234/db" `shouldBe`+ [ ("user","db")+ , ("password","pass")+ , ("host","ec2-1-1-1-1.compute-1.amazonaws.com")+ , ("port","1234")+ , ("dbname","db")+ ]