aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/Test/Graylog/UDP.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/Test/Graylog/UDP.hs')
-rw-r--r--test/Test/Graylog/UDP.hs22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/Test/Graylog/UDP.hs b/test/Test/Graylog/UDP.hs
index d62f11a..6534c69 100644
--- a/test/Test/Graylog/UDP.hs
+++ b/test/Test/Graylog/UDP.hs
@@ -1,16 +1,23 @@
1{-# LANGUAGE OverloadedStrings #-} 1{-# LANGUAGE OverloadedStrings #-}
2{-# LANGUAGE TemplateHaskell #-}
2 3
3module Test.Graylog.UDP where 4module Test.Graylog.UDP where
4 5
6import qualified Data.ByteString as BS
7import Data.FileEmbed
8import qualified Data.Text.Encoding as T
5import Test.Tasty 9import Test.Tasty
6import Test.Tasty.HUnit 10import Test.Tasty.HUnit
7 11
8import Graylog.UDP 12import Graylog.UDP
9 13
14largeSample :: BS.ByteString
15largeSample = $(embedFile "./test/Test/Graylog/UDP/large-sample.json")
16
10tests :: TestTree 17tests :: TestTree
11tests = testGroup "Test.Graylog.UDP" 18tests = testGroup "Test.Graylog.UDP"
12 {-[ testCase "Send: Sample" case_validateSomething-}
13 [ testCase "Send sample message." case_sendSample 19 [ testCase "Send sample message." case_sendSample
20 , testCase "Send large sample message." case_sendLargeSample
14 ] 21 ]
15 22
16case_sendSample :: IO () 23case_sendSample :: IO ()
@@ -18,6 +25,17 @@ case_sendSample = do
18 eglog <- openGraylog "192.168.99.100" "12201" defaultChunkSize 25 eglog <- openGraylog "192.168.99.100" "12201" defaultChunkSize
19 case eglog of 26 case eglog of
20 Left e -> assertFailure e 27 Left e -> assertFailure e
21 Right g -> sendLog g sample 28 Right g -> sendLog g sample >> closeGraylog g
22 where 29 where
23 sample = simpleGelf "localhost" "hello world!" 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