diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-21 04:23:30 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-21 04:23:30 -0500 |
| commit | 5272d84bf3861fb301ccf167fefded513afc42ab (patch) | |
| tree | f38e2f9c6a4f76d879b8146522e9f023128a58b2 /Omni/Agent/LogTest.hs | |
| parent | 514686242b49c3f457a2521554ebf8df5e3ba3be (diff) | |
| parent | d7137870db73e39181be61088a2132343f400998 (diff) | |
Merge branch 'live' into task/t-1ne7VoO
Diffstat (limited to 'Omni/Agent/LogTest.hs')
| -rw-r--r-- | Omni/Agent/LogTest.hs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Omni/Agent/LogTest.hs b/Omni/Agent/LogTest.hs new file mode 100644 index 0000000..0d085b1 --- /dev/null +++ b/Omni/Agent/LogTest.hs @@ -0,0 +1,72 @@ +{-# 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 = "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 = "executing 1 tools in 1 batch(es)", + leLevel = Nothing, + leToolName = Nothing, + leBatches = Just [["grep"]], + leMethod = Nothing, + lePath = Nothing + } + format entry @?= Just "🤖 THOUGHT: Planning tool execution (grep)" + + let entry2 = + LogEntry + { leMessage = "some random log", + leLevel = Nothing, + leToolName = Nothing, + leBatches = Nothing, + leMethod = Nothing, + lePath = Nothing + } + format entry2 @?= Nothing + + let entry3 = + LogEntry + { leMessage = "some error", + leLevel = Just "error", + leToolName = Nothing, + leBatches = Nothing, + leMethod = Nothing, + lePath = Nothing + } + format entry3 @?= Just "❌ ERROR: some error" + +(@?=) :: (Eq a, Show a) => a -> a -> IO () +(@?=) = (Test.@?=) |
