diff options
Diffstat (limited to 'Omni')
| -rw-r--r-- | Omni/Agent.hs | 13 | ||||
| -rw-r--r-- | Omni/Agent/LogTest.hs | 74 |
2 files changed, 12 insertions, 75 deletions
diff --git a/Omni/Agent.hs b/Omni/Agent.hs index d53bccd..f3fc29d 100644 --- a/Omni/Agent.hs +++ b/Omni/Agent.hs @@ -10,6 +10,7 @@ module Omni.Agent where import Alpha import qualified Data.Text as Text import qualified Omni.Agent.Core as Core +import qualified Omni.Agent.Log as Log import qualified Omni.Agent.Worker as Worker import qualified Omni.Cli as Cli import qualified Omni.Test as Test @@ -63,7 +64,17 @@ move args | otherwise = putStrLn (Cli.usage help) test :: Test.Tree -test = Test.group "Omni.Agent" [unitTests] +test = Test.group "Omni.Agent" [unitTests, logTests] + +logTests :: Test.Tree +logTests = + Test.group + "Log tests" + [ Test.unit "Log.emptyStatus" <| do + let s = Log.emptyStatus "worker-1" + Log.statusWorker s Test.@?= "worker-1" + Log.statusFiles s Test.@?= 0 + ] unitTests :: Test.Tree unitTests = diff --git a/Omni/Agent/LogTest.hs b/Omni/Agent/LogTest.hs deleted file mode 100644 index 97b558d..0000000 --- a/Omni/Agent/LogTest.hs +++ /dev/null @@ -1,74 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE NoImplicitPrelude #-} - --- : out agent-log-test -module Omni.Agent.LogTest where - -import Alpha -import Omni.Agent.Log -import qualified Omni.Test as Test - -main :: IO () -main = Test.run tests - -tests :: Test.Tree -tests = - Test.group - "Omni.Agent.Log" - [ Test.unit "Parse LogEntry" testParse, - Test.unit "Format LogEntry" testFormat - ] - -testParse :: IO () -testParse = do - let json = "{\"message\": \"executing 1 tools in 1 batch(es)\", \"batches\": [[\"grep\"]]}" - let expected = - LogEntry - { leMessage = Just "executing 1 tools in 1 batch(es)", - leLevel = Nothing, - leToolName = Nothing, - leBatches = Just [["grep"]], - leMethod = Nothing, - lePath = Nothing - } - parseLine json @?= Just expected - -testFormat :: IO () -testFormat = do - let entry = - LogEntry - { leMessage = Just "executing 1 tools in 1 batch(es)", - leLevel = Nothing, - leToolName = Nothing, - leBatches = Just [["grep"]], - leMethod = Nothing, - lePath = Nothing - } - -- Expect NO emoji - formatLogEntry entry @?= Just "THOUGHT: Planning tool execution (grep)" - - let entry2 = - LogEntry - { leMessage = Just "some random log", - leLevel = Nothing, - leToolName = Nothing, - leBatches = Nothing, - leMethod = Nothing, - lePath = Nothing - } - formatLogEntry entry2 @?= Nothing - - let entry3 = - LogEntry - { leMessage = Just "some error", - leLevel = Just "error", - leToolName = Nothing, - leBatches = Nothing, - leMethod = Nothing, - lePath = Nothing - } - -- Expect NO emoji - formatLogEntry entry3 @?= Just "ERROR: some error" - -(@?=) :: (Eq a, Show a) => a -> a -> IO () -(@?=) = (Test.@?=) |
