Skip to content

Commit

Permalink
Simply test of getService
Browse files Browse the repository at this point in the history
  • Loading branch information
steshaw committed Mar 13, 2017
1 parent 139e0d2 commit fd0cb70
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions fastly.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ test-suite fastly-test
main-is: Spec.hs
build-depends: base
, fastly
, text
ghc-options: -threaded -rtsopts -with-rtsopts=-N
default-language: Haskell2010

Expand Down
4 changes: 4 additions & 0 deletions src/Network/Fastly.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module Network.Fastly
( FastlyAuth(..)
, Username(..)
, Password(..)
, FastlyClient
, fastlyClient
, fastly
, FastlyResponse(..)
-- Account
{-
Expand Down Expand Up @@ -112,6 +114,8 @@ module Network.Fastly
, getServiceDetails
, getServiceByName
, getService
, ServiceId(..)
, Service(..)
{-
, createService
, deleteService
Expand Down
26 changes: 25 additions & 1 deletion test/Spec.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,26 @@
{-# LANGUAGE OverloadedStrings #-}

import qualified Network.Fastly as F
import qualified System.Environment as Env
import qualified Data.Text as T
import qualified Data.Text.IO as T

testGetService token serviceId = do
r <- F.fastly token (\client -> F.getService client serviceId)
case r of
Left err ->
T.putStrLn (T.intercalate " " ["Error: ", T.pack (show err)])
Right service ->
T.putStrLn (T.intercalate " " ["Service name: ", F.serviceName service])

tests token serviceId = do
testGetService token serviceId

main :: IO ()
main = putStrLn "Test suite not yet implemented"
main = do
args <- Env.getArgs
case args of
[token, serviceId] -> tests (T.pack token) (F.ServiceId (T.pack serviceId))
_ -> do
progName <- Env.getProgName
putStrLn ("usage: " ++ progName ++ " <token> <serviceId>")

0 comments on commit fd0cb70

Please sign in to comment.