diff options
Diffstat (limited to 'test/Test/Graylog/UDP.hs')
-rw-r--r-- | test/Test/Graylog/UDP.hs | 22 |
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 | ||
3 | module Test.Graylog.UDP where | 4 | module Test.Graylog.UDP where |
4 | 5 | ||
6 | import qualified Data.ByteString as BS | ||
7 | import Data.FileEmbed | ||
8 | import qualified Data.Text.Encoding as T | ||
5 | import Test.Tasty | 9 | import Test.Tasty |
6 | import Test.Tasty.HUnit | 10 | import Test.Tasty.HUnit |
7 | 11 | ||
8 | import Graylog.UDP | 12 | import Graylog.UDP |
9 | 13 | ||
14 | largeSample :: BS.ByteString | ||
15 | largeSample = $(embedFile "./test/Test/Graylog/UDP/large-sample.json") | ||
16 | |||
10 | tests :: TestTree | 17 | tests :: TestTree |
11 | tests = testGroup "Test.Graylog.UDP" | 18 | tests = 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 | ||
16 | case_sendSample :: IO () | 23 | case_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 | |||
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 | |||