diff options
Diffstat (limited to 'Omni/Agent/LogTest.hs')
| -rw-r--r-- | Omni/Agent/LogTest.hs | 62 |
1 files changed, 57 insertions, 5 deletions
diff --git a/Omni/Agent/LogTest.hs b/Omni/Agent/LogTest.hs index 0d085b1..518147e 100644 --- a/Omni/Agent/LogTest.hs +++ b/Omni/Agent/LogTest.hs @@ -5,6 +5,7 @@ module Omni.Agent.LogTest where import Alpha +import qualified Data.Set as Set import Omni.Agent.Log import qualified Omni.Test as Test @@ -16,7 +17,9 @@ tests = Test.group "Omni.Agent.Log" [ Test.unit "Parse LogEntry" testParse, - Test.unit "Format LogEntry" testFormat + Test.unit "Format LogEntry" testFormat, + Test.unit "Update Status" testUpdateStatus, + Test.unit "Render Status" testRenderStatus ] testParse :: IO () @@ -29,7 +32,8 @@ testParse = do leToolName = Nothing, leBatches = Just [["grep"]], leMethod = Nothing, - lePath = Nothing + lePath = Nothing, + leTimestamp = Nothing } parseLine json @?= Just expected @@ -42,7 +46,8 @@ testFormat = do leToolName = Nothing, leBatches = Just [["grep"]], leMethod = Nothing, - lePath = Nothing + lePath = Nothing, + leTimestamp = Nothing } format entry @?= Just "🤖 THOUGHT: Planning tool execution (grep)" @@ -53,7 +58,8 @@ testFormat = do leToolName = Nothing, leBatches = Nothing, leMethod = Nothing, - lePath = Nothing + lePath = Nothing, + leTimestamp = Nothing } format entry2 @?= Nothing @@ -64,9 +70,55 @@ testFormat = do leToolName = Nothing, leBatches = Nothing, leMethod = Nothing, - lePath = Nothing + lePath = Nothing, + leTimestamp = Nothing } format entry3 @?= Just "❌ ERROR: some error" +testUpdateStatus :: IO () +testUpdateStatus = do + let s0 = initialStatus "worker-1" + let e1 = + LogEntry + { leMessage = "executing 1 tools in 1 batch(es)", + leLevel = Nothing, + leToolName = Nothing, + leBatches = Just [["grep"]], + leMethod = Nothing, + lePath = Nothing, + leTimestamp = Just "12:00:00" + } + let s1 = updateStatus e1 s0 + sLastActivity s1 @?= "🤖 THOUGHT: Planning tool execution (grep)" + sStartTime s1 @?= Just "12:00:00" + + let e2 = + LogEntry + { leMessage = "ide-fs", + leLevel = Nothing, + leToolName = Nothing, + leBatches = Nothing, + leMethod = Just "readFile", + lePath = Just "/path/to/file", + leTimestamp = Just "12:00:01" + } + let s2 = updateStatus e2 s1 + sLastActivity s2 @?= "📂 READ: /path/to/file" + Set.member "/path/to/file" (sFiles s2) @?= True + sStartTime s2 @?= Just "12:00:00" -- Should preserve start time + +testRenderStatus :: IO () +testRenderStatus = do + let s = + Status + { sWorkerName = "worker-1", + sTaskId = Just "t-123", + sFiles = Set.fromList ["file1", "file2"], + sStartTime = Just "12:00", + sLastActivity = "Running..." + } + let output = renderStatus s + output @?= "[Worker: worker-1] Task: t-123 | Files: 2\nRunning..." + (@?=) :: (Eq a, Show a) => a -> a -> IO () (@?=) = (Test.@?=) |
