]>
Commit | Line | Data |
---|---|---|
b23afe7b | 1 | {-# LANGUAGE OverloadedStrings #-} |
f82a8dfc | 2 | {-# LANGUAGE TemplateHaskell #-} |
b23afe7b | 3 | |
15981d57 A |
4 | module Test.Graylog.UDP where |
5 | ||
f82a8dfc A |
6 | import qualified Data.ByteString as BS |
7 | import Data.FileEmbed | |
8 | import qualified Data.Text.Encoding as T | |
15981d57 A |
9 | import Test.Tasty |
10 | import Test.Tasty.HUnit | |
11 | ||
b23afe7b A |
12 | import Graylog.UDP |
13 | ||
f82a8dfc A |
14 | largeSample :: BS.ByteString |
15 | largeSample = $(embedFile "./test/Test/Graylog/UDP/large-sample.json") | |
16 | ||
15981d57 A |
17 | tests :: TestTree |
18 | tests = 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 |
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 | |
f82a8dfc | 28 | Right g -> sendLog g sample >> closeGraylog g |
b23afe7b A |
29 | where |
30 | sample = simpleGelf "localhost" "hello world!" | |
f82a8dfc A |
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 |