]> git.immae.eu Git - github/fretlink/haskell-graylog.git/commitdiff
Added testing for UDP method.
authorAndrewRademacher <andrew.rademacher@smrxt.com>
Wed, 24 Feb 2016 23:24:19 +0000 (17:24 -0600)
committerAndrewRademacher <andrew.rademacher@smrxt.com>
Wed, 24 Feb 2016 23:24:19 +0000 (17:24 -0600)
graylog.cabal
src/Graylog/Gelf.hs
src/Graylog/UDP.hs [new file with mode: 0644]
test/Main.hs [new file with mode: 0644]
test/Test/Graylog/UDP.hs [new file with mode: 0644]

index d7d1163f2ea508505c1f6cfadee1502a23cf1a93..b3c1a5308b8e6710dba02a1dbe8982db545de785 100644 (file)
@@ -24,7 +24,33 @@ library
    
                      ,  aeson
                      ,  aeson-casing
+                     ,  network
                      ,  scientific
                      ,  text
                      ,  time
                      ,  vector
+
+test-suite test-state
+   type:                exitcode-stdio-1.0
+   main-is:             Main.hs
+   hs-source-dirs:      test
+   default-language:    Haskell2010
+
+   ghc-options:         -Wall -threaded -with-rtsopts=-N -rtsopts
+
+   other-modules:       Test.Graylog.UDP
+
+   build-depends:       base           ==4.*
+
+                     ,  graylog
+
+                     ,  aeson
+                     ,  aeson-casing
+                     ,  network
+                     ,  scientific
+                     ,  tasty
+                     ,  tasty-hunit
+                     ,  text
+                     ,  time
+                     ,  vector
+
index 67e0de7e219e347a3c4099d4222b8315936ed919..32b932121911f85882c3b07b9aa995af01a4bb68 100644 (file)
@@ -7,24 +7,21 @@ module Graylog.Gelf where
 import           Data.Aeson        (ToJSON (..), Value (..), genericToJSON,
                                     toJSON)
 import           Data.Aeson.Casing
-import           Data.Scientific
 import           Data.Text         (Text)
 import           Data.Time
 import           Data.Typeable
-import           Data.Vector
 import           GHC.Generics
 
 data GELF
    = GELF
-      { _gelfVersion          :: Version
-      , _gelfHost             :: Text
-      , _gelfShortMessage     :: Text
-      , _gelfFullMessage      :: Maybe Text
-      , _gelfTimestamp        :: Maybe UTCTime
-      , _gelfLevel            :: Maybe SyslogLevel
-      , _gelfLine             :: Maybe Word
-      , _gelfFile             :: Maybe Text
-      , _gelfAdditionalFields :: Vector Field
+      { _gelfVersion      :: Version
+      , _gelfHost         :: Text
+      , _gelfShortMessage :: Text
+      , _gelfFullMessage  :: Maybe Text
+      , _gelfTimestamp    :: Maybe UTCTime
+      , _gelfLevel        :: Maybe SyslogLevel
+      , _gelfLine         :: Maybe Word
+      , _gelfFile         :: Maybe Text
       }
    deriving (Show, Typeable, Generic)
 
@@ -62,15 +59,3 @@ instance ToJSON SyslogLevel where
    toJSON Notice        = Number 5
    toJSON Informational = Number 6
    toJSON Debug         = Number 7
-
---
-
-data Field
-   = FieldString Text
-   | FieldNumber Scientific
-   deriving (Eq, Show, Typeable, Generic)
-
-instance ToJSON Field where
-   toJSON (FieldString s) = String s
-   toJSON (FieldNumber n) = Number n
-
diff --git a/src/Graylog/UDP.hs b/src/Graylog/UDP.hs
new file mode 100644 (file)
index 0000000..6aec108
--- /dev/null
@@ -0,0 +1,19 @@
+module Graylog.UDP
+   ( Graylog (..)
+   , sendLog
+
+   , module Graylog.Gelf
+   ) where
+
+import           Network.Socket
+
+import           Graylog.Gelf
+
+data Graylog
+   = Graylog
+      { _graylogHost :: String
+      , _graylogPort :: String
+      }
+
+sendLog :: Graylog -> GELF -> IO ()
+sendLog glog msg = undefined
diff --git a/test/Main.hs b/test/Main.hs
new file mode 100644 (file)
index 0000000..604b65a
--- /dev/null
@@ -0,0 +1,12 @@
+import qualified Test.Graylog.UDP (tests)
+
+import           Test.Tasty
+
+main :: IO ()
+main = defaultMain tests
+
+tests :: TestTree
+tests = testGroup "Graylog Library"
+   [ Test.Graylog.UDP.tests
+   ]
+
diff --git a/test/Test/Graylog/UDP.hs b/test/Test/Graylog/UDP.hs
new file mode 100644 (file)
index 0000000..67da6fe
--- /dev/null
@@ -0,0 +1,13 @@
+module Test.Graylog.UDP where
+
+import           Test.Tasty
+import           Test.Tasty.HUnit
+
+tests :: TestTree
+tests = testGroup "Test.Graylog.UDP"
+   [ testCase "Validation: Something" case_validateSomething
+   ]
+
+case_validateSomething :: IO ()
+case_validateSomething = return ()
+