Skip to content

Commit

Permalink
Use hpack and exitcode-stdio-1.0 because detailed-0.9 is not supporte…
Browse files Browse the repository at this point in the history
…d by hpack
  • Loading branch information
Dan Fithian committed Dec 19, 2017
1 parent 9423218 commit 4fa6728
Show file tree
Hide file tree
Showing 12 changed files with 299 additions and 458 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
dist
cabal-dev
*.cabal
*.o
*.hi
*.chi
Expand Down
75 changes: 0 additions & 75 deletions datadog.cabal

This file was deleted.

86 changes: 86 additions & 0 deletions package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: datadog
version: '0.3.0.0'
author: Ian Duncan
maintainer: [email protected]
license: MIT
license-file: LICENSE
synopsis: 'Datadog client for Haskell. Supports both the HTTP API and StatsD.'
homepage: 'https://github.com/iand675/datadog'
category: Network
build-type: Simple

default-extensions:
- ConstraintKinds
- DataKinds
- DeriveDataTypeable
- DeriveGeneric
- EmptyDataDecls
- FlexibleContexts
- FlexibleInstances
- GADTs
- GeneralizedNewtypeDeriving
- LambdaCase
- MultiParamTypeClasses
- NamedFieldPuns
# - NoImplicitPrelude
- NoMonomorphismRestriction
- OverloadedStrings
- PackageImports
- PolyKinds
- QuasiQuotes
- RankNTypes
- RecordWildCards
- ScopedTypeVariables
- StandaloneDeriving
- TemplateHaskell
- TupleSections
- TypeFamilies
- TypeOperators
- ViewPatterns

ghc-options:
- -Wall
# - -Werror
- -fwarn-tabs
- -O2

dependencies:
- aeson
- auto-update
- base
- buffer-builder
- bytestring
- dlist
- http-client
- http-client-tls
- http-types
- lens
- lifted-base
- monad-control
- network
- old-locale
- text
- time
- transformers-base
- unordered-containers
- vector

library:
source-dirs: src

tests:
datadog-api-test:
main: Spec.hs
source-dirs:
- test
dependencies:
- base
- Cabal
- exceptions
- hspec
- network
- lens
- random
- text
- time
- datadog
92 changes: 0 additions & 92 deletions src/Network/Datadog/Wai.hs

This file was deleted.

6 changes: 6 additions & 0 deletions test/Spec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Hspec (hspec)

import Test.Network.Datadog (spec)

main :: IO ()
main = hspec spec
36 changes: 16 additions & 20 deletions test/Test/Network/Datadog.hs
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
module Test.Network.Datadog (tests) where
module Test.Network.Datadog (spec) where

import Test.Hspec (Spec, describe)

import Distribution.TestSuite
import qualified Test.Network.Datadog.Check as Check (spec)
import qualified Test.Network.Datadog.Downtime as Downtime (spec)
import qualified Test.Network.Datadog.Event as Event (spec)
import qualified Test.Network.Datadog.Host as Host (spec)
import qualified Test.Network.Datadog.Monitor as Monitor (spec)
import qualified Test.Network.Datadog.StatsD as StatsD (spec)

import qualified Test.Network.Datadog.StatsD as StatsD (tests)
import qualified Test.Network.Datadog.Check as Check (tests)
import qualified Test.Network.Datadog.Downtime as Downtime (tests)
import qualified Test.Network.Datadog.Event as Event (tests)
import qualified Test.Network.Datadog.Monitor as Monitor (tests)
import qualified Test.Network.Datadog.Host as Host (tests)


tests :: IO [Test]
tests = map (\(s,t) -> Group s False t)
<$> mapM (\(s,tm) -> fmap (\t -> (s,t)) tm)
[("StatsD", StatsD.tests)
,("Check", Check.tests)
,("Downtime", Downtime.tests)
,("Event", Event.tests)
,("Host", Host.tests)
,("Monitor", Monitor.tests)
]
spec :: Spec
spec = describe "Datadog spec" $ do
describe "StatsD spec" StatsD.spec
describe "Check spec" Check.spec
describe "Downtime spec" Downtime.spec
describe "Event spec" Event.spec
describe "Host spec" Host.spec
describe "Monitor spec" Monitor.spec
69 changes: 30 additions & 39 deletions test/Test/Network/Datadog/Check.hs
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
{-# LANGUAGE OverloadedStrings #-}

module Test.Network.Datadog.Check (tests) where


import Control.Concurrent (threadDelay)
import Control.Exception

import Distribution.TestSuite

import Network.Datadog (Environment, loadKeysFromEnv, createEnvironment)
import Network.Datadog.Check hiding (tags)

tests :: IO [Test]
tests = return
[ Test TestInstance { run = testCheckRecord
, name = "Test recording of a status check"
, tags = ["Check"]
, options = []
, setOption = \_ _ -> Left ""
}
]


environment :: IO Environment
environment = createEnvironment =<< loadKeysFromEnv


testCheckRecord :: IO Progress
testCheckRecord = do
module Test.Network.Datadog.Check (spec) where

import Test.Hspec (Spec, describe, it)

import Network.Datadog (Environment, createEnvironment, loadKeysFromEnv)
import Network.Datadog.Check
( CheckResult (CheckResult)
, CheckStatus (CheckOk)
, checkResultCheck
, checkResultHostName
, checkResultMessage
, checkResultStatus
, checkResultTags
, checkResultTimestamp
, recordCheck
)

spec :: Spec
spec = it "Records a status check" $ do
let environment :: IO Environment
environment = createEnvironment =<< loadKeysFromEnv
check = CheckResult
{ checkResultCheck = "Datadog Test Check"
, checkResultHostName = "development"
, checkResultStatus = CheckOk
, checkResultTimestamp = Nothing
, checkResultMessage = Nothing
, checkResultTags = []
}
env <- environment
let check = CheckResult { checkResultCheck = "Datadog Test Check"
, checkResultHostName = "development"
, checkResultStatus = CheckOk
, checkResultTimestamp = Nothing
, checkResultMessage = Nothing
, checkResultTags = []
}
let computation = const (Finished Pass) <$> const (recordCheck env check) <$> threadDelay 500000
catch computation (\e -> return $ Finished $ Fail $ show (e :: SomeException))
recordCheck env check
Loading

0 comments on commit 4fa6728

Please sign in to comment.