]> git.immae.eu Git - github/fretlink/haskell-graylog.git/blame_incremental - test/Test/Graylog/UDP.hs
Merge pull request #3 from antoine-fl/bump_lts
[github/fretlink/haskell-graylog.git] / test / Test / Graylog / UDP.hs
... / ...
CommitLineData
1{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE TemplateHaskell #-}
3
4module Test.Graylog.UDP where
5
6import qualified Data.ByteString as BS
7import Data.FileEmbed
8import qualified Data.Text.Encoding as T
9import Test.Tasty
10import Test.Tasty.HUnit
11
12import Graylog.UDP
13
14largeSample :: BS.ByteString
15largeSample = $(embedFile "./test/Test/Graylog/UDP/large-sample.json")
16
17tests :: TestTree
18tests = testGroup "Test.Graylog.UDP"
19 [ testCase "Send sample message." case_sendSample
20 , testCase "Send large sample message." case_sendLargeSample
21 ]
22
23case_sendSample :: IO ()
24case_sendSample = do
25 eglog <- openGraylog "192.168.99.100" "12201" defaultChunkSize
26 case eglog of
27 Left e -> assertFailure e
28 Right g -> sendLog g sample >> closeGraylog g
29 where
30 sample = simpleGelf "localhost" "hello world!"
31
32case_sendLargeSample :: IO ()
33case_sendLargeSample = do
34 eglog <- openGraylog "192.168.99.100" "12201" defaultChunkSize
35 case eglog of
36 Left e -> assertFailure e
37 Right g -> sendLog g sample >> closeGraylog g
38 where
39 sample = (simpleGelf "localhost" "hello world!")
40 { _gelfFullMessage = Just $ T.decodeUtf8 largeSample }
41