]> git.immae.eu Git - github/fretlink/haskell-graylog.git/blobdiff - test/Test/Graylog/UDP.hs
Implemented UDP chunking.
[github/fretlink/haskell-graylog.git] / test / Test / Graylog / UDP.hs
index d62f11a25a0e39b078139181eed040306a6bf2f9..6534c6955694efc62044a337acd3cd698df460ca 100644 (file)
@@ -1,16 +1,23 @@
 {-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE TemplateHaskell   #-}
 
 module Test.Graylog.UDP where
 
+import qualified Data.ByteString    as BS
+import           Data.FileEmbed
+import qualified Data.Text.Encoding as T
 import           Test.Tasty
 import           Test.Tasty.HUnit
 
 import           Graylog.UDP
 
+largeSample :: BS.ByteString
+largeSample = $(embedFile "./test/Test/Graylog/UDP/large-sample.json")
+
 tests :: TestTree
 tests = testGroup "Test.Graylog.UDP"
-   {-[ testCase "Send: Sample" case_validateSomething-}
    [ testCase "Send sample message." case_sendSample
+   , testCase "Send large sample message." case_sendLargeSample
    ]
 
 case_sendSample :: IO ()
@@ -18,6 +25,17 @@ case_sendSample = do
    eglog <- openGraylog "192.168.99.100" "12201" defaultChunkSize
    case eglog of
       Left  e -> assertFailure e
-      Right g -> sendLog g sample
+      Right g -> sendLog g sample >> closeGraylog g
    where
       sample = simpleGelf "localhost" "hello world!"
+
+case_sendLargeSample :: IO ()
+case_sendLargeSample = do
+   eglog <- openGraylog "192.168.99.100" "12201" defaultChunkSize
+   case eglog of
+      Left  e -> assertFailure e
+      Right g -> sendLog g sample >> closeGraylog g
+   where
+      sample = (simpleGelf "localhost" "hello world!")
+                  { _gelfFullMessage = Just $ T.decodeUtf8 largeSample }
+