]> git.immae.eu Git - github/fretlink/haskell-graylog.git/blame - test/Test/Graylog/UDP.hs
Implemented UDP chunking.
[github/fretlink/haskell-graylog.git] / test / Test / Graylog / UDP.hs
CommitLineData
b23afe7b 1{-# LANGUAGE OverloadedStrings #-}
f82a8dfc 2{-# LANGUAGE TemplateHaskell #-}
b23afe7b 3
15981d57
A
4module Test.Graylog.UDP where
5
f82a8dfc
A
6import qualified Data.ByteString as BS
7import Data.FileEmbed
8import qualified Data.Text.Encoding as T
15981d57
A
9import Test.Tasty
10import Test.Tasty.HUnit
11
b23afe7b
A
12import Graylog.UDP
13
f82a8dfc
A
14largeSample :: BS.ByteString
15largeSample = $(embedFile "./test/Test/Graylog/UDP/large-sample.json")
16
15981d57
A
17tests :: TestTree
18tests = testGroup "Test.Graylog.UDP"
b23afe7b 19 [ testCase "Send sample message." case_sendSample
f82a8dfc 20 , testCase "Send large sample message." case_sendLargeSample
15981d57
A
21 ]
22
b23afe7b
A
23case_sendSample :: IO ()
24case_sendSample = do
25 eglog <- openGraylog "192.168.99.100" "12201" defaultChunkSize
26 case eglog of
27 Left e -> assertFailure e
f82a8dfc 28 Right g -> sendLog g sample >> closeGraylog g
b23afe7b
A
29 where
30 sample = simpleGelf "localhost" "hello world!"
f82a8dfc
A
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