Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rollbar-cli/rollbar-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ test-suite spec
build-depends:
base >=4.13 && <5
, rollbar-cli
, bytestring >=0.10 && <1
default-language: Haskell2010
1 change: 1 addition & 0 deletions rollbar-client/rollbar-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ test-suite spec
, text
, unordered-containers
, yaml
, bytestring >=0.10 && <1
default-language: Haskell2010
14 changes: 7 additions & 7 deletions rollbar-client/src/Rollbar/Client/Item.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ instance ToJSON Item where
let dataFields =
[ "environment" .= itemEnvironment
, "body" .= itemBody
, "level" .= itemLevel
, "platform" .= itemPlatform
, "language" .= itemLanguage
, "framework" .= itemFramework
, "request" .= itemRequest
, "server" .= itemServer
, "notifier" .= itemNotifier
] ++ catMaybes
[ ("custom" .=) <$> custom
[ ("level" .=) <$> itemLevel
, ("platform" .=) <$> itemPlatform
, ("language" .=) <$> itemLanguage
, ("framework" .=) <$> itemFramework
, ("request" .=) <$> itemRequest
, ("server" .=) <$> itemServer
, ("custom" .=) <$> custom
, ("fingerprint" .=) <$> fingerprint
, ("title" .=) <$> title
, ("uuid" .=) <$> uuid
Expand Down
29 changes: 28 additions & 1 deletion rollbar-client/test/Rollbar/ClientSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import qualified Data.Aeson.KeyMap as KM

import Control.Monad.Reader
import Data.Aeson
import Data.Text
import qualified Data.ByteString.Lazy as DBL
import Data.Text.Encoding
import Data.Text as T
import Data.Yaml.Config
import Rollbar.Client
import Test.Hspec
Expand Down Expand Up @@ -143,3 +145,28 @@ spec = do
reportDeploy deploy

deployId `shouldSatisfy` (> 0)

describe "ToJSON Item" $ do
context "when serializing to JSON" $ do
let item = Item
{ itemEnvironment = Environment "test"
, itemBody = Body { bodyPayload = PayloadMessage (Message "Test" mempty) }
, itemLevel = Just LevelInfo
, itemPlatform = Just "haskell"
, itemLanguage = Just "Haskell"
, itemFramework = Just "GHC"
, itemRequest = Nothing
, itemServer = Nothing
, custom = Just mempty
, title = Nothing
, uuid = Just "12345"
, fingerprint = Nothing
, itemNotifier = Notifier "rollbar-client" "1.1.0"
}
jsonItem = decodeUtf8 $ DBL.toStrict $ encode item

it "omits fields if they are Nothing values" $
T.unpack jsonItem `shouldNotContain` "\"server\""

it "includes fields if they are Just values" $
T.unpack jsonItem `shouldContain` "\"platform\":\"haskell\""
2 changes: 1 addition & 1 deletion rollbar-wai/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ library:
- text >= 1.2 && < 2.1
- unordered-containers >= 0.2 && < 1
- wai >= 3.2 && < 4
- wai-extra >= 3.0 && < 4
- wai-extra < 3.1.17 # TODO: update breaks yesod-core, see https://github.com/yesodweb/yesod/issues/1854

executables:
wai-example:
Expand Down
3 changes: 2 additions & 1 deletion rollbar-wai/rollbar-wai.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ library
, text >=1.2 && <2.1
, unordered-containers >=0.2 && <1
, wai >=3.2 && <4
, wai-extra >=3.0 && <4
, wai-extra >=3.0 && < 3.1.17 -- TODO: update breaks yesod-core, see https://github.com/yesodweb/yesod/issues/1854
default-language: Haskell2010

executable wai-example
Expand Down Expand Up @@ -101,4 +101,5 @@ test-suite spec
, unordered-containers
, wai
, warp >=3.3 && <4
, bytestring >=0.10 && <1
default-language: Haskell2010
1 change: 1 addition & 0 deletions rollbar-yesod/rollbar-yesod.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ test-suite spec
, wai
, yesod-core
, yesod-test >=1.6 && <2
, bytestring >=0.10 && <1
default-language: Haskell2010
Loading