]> git.immae.eu Git - github/fretlink/haskell-graylog.git/blob - test/Test/Graylog/UDP.hs
Implemented UDP chunking.
[github/fretlink/haskell-graylog.git] / test / Test / Graylog / UDP.hs
1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE TemplateHaskell #-}
3
4 module Test.Graylog.UDP where
5
6 import qualified Data.ByteString as BS
7 import Data.FileEmbed
8 import qualified Data.Text.Encoding as T
9 import Test.Tasty
10 import Test.Tasty.HUnit
11
12 import Graylog.UDP
13
14 largeSample :: BS.ByteString
15 largeSample = $(embedFile "./test/Test/Graylog/UDP/large-sample.json")
16
17 tests :: TestTree
18 tests = testGroup "Test.Graylog.UDP"
19 [ testCase "Send sample message." case_sendSample
20 , testCase "Send large sample message." case_sendLargeSample
21 ]
22
23 case_sendSample :: IO ()
24 case_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
32 case_sendLargeSample :: IO ()
33 case_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