Source

stash-log-parser / logparser / tests / Properties.hs

Diff from to

logparser/tests/Properties.hs

 {-# LANGUAGE OverloadedStrings #-}
 
--- | Tests for the 'Data.Hashable' module.  We test functions by
--- comparing the C and Haskell implementations.
-
 module Main (main) where
 
 import qualified Data.ByteString.Lazy.Char8 as L
 import Stash.Log.Analyser
 import Stash.Log.Parser
 import Stash.Log.GitOpsAnalyser
+import Stash.Log.Common (sortLogFiles)
 import Data.Maybe
 import Test.QuickCheck hiding ((.&.))
 import Test.Framework (Test, defaultMain, testGroup)
     (protocolCount dataLogLines)
 
 ------------------------------------------------------------------------
+test_sortFilesAsc = H.assertEqual
+    "Should sort the given files correctly"
+    ["atlassian-stash-access-2012-11-29.1.log.bz2",
+     "atlassian-stash-access-2012-11-29.2.log.bz2",
+     "atlassian-stash-access-2012-11-29.4.log.bz2",
+     "atlassian-stash-access-2012-11-29.10.log.bz2",
+     "atlassian-stash-access.log"]
+     (sortLogFiles input)
+    where input = ["atlassian-stash-access-2012-11-29.4.log.bz2",
+                     "atlassian-stash-access-2012-11-29.1.log.bz2",
+                     "atlassian-stash-access-2012-11-29.10.log.bz2",
+                     "atlassian-stash-access.log",
+                     "atlassian-stash-access-2012-11-29.2.log.bz2"]
+
+------------------------------------------------------------------------
 -- Test harness
 
 main :: IO ()
         ,testCase "analyser/dataConcurrentConn logDateEqMin" test_plotDataConcurrentConn
         ,testCase "analyser/dataConcurrentConn logDateEqHour" test_plotDataConcurrentConnHour
       ],
+      testGroup "Common"
+      [
+        testCase "common/sortLogFiles" test_sortFilesAsc
+      ],
       testGroup "parser"
       [ testCase "parser/parse empty String" test_logLineParserEmpty
         ,testCase "parser/parse single line" test_logLineParseSingleLine