diff options
Diffstat (limited to 'Omni/Agent')
| -rw-r--r-- | Omni/Agent/Git.hs | 6 | ||||
| -rw-r--r-- | Omni/Agent/LogTest.hs | 74 |
2 files changed, 3 insertions, 77 deletions
diff --git a/Omni/Agent/Git.hs b/Omni/Agent/Git.hs index a64eee8..4c06cf6 100644 --- a/Omni/Agent/Git.hs +++ b/Omni/Agent/Git.hs @@ -205,11 +205,11 @@ isMerged repo branch target = do pure (code == Exit.ExitSuccess) listBranches :: FilePath -> Text -> IO [Text] -listBranches repo pattern = do - let cmd = (Process.proc "git" ["branch", "--list", Text.unpack pattern, "--format=%(refname:short)"]) {Process.cwd = Just repo} +listBranches repo pat = do + let cmd = (Process.proc "git" ["branch", "--list", Text.unpack pat, "--format=%(refname:short)"]) {Process.cwd = Just repo} (code, out, _) <- Process.readCreateProcessWithExitCode cmd "" case code of - Exit.ExitSuccess -> pure <| filter (not . Text.null) (Text.lines (Text.pack out)) + Exit.ExitSuccess -> pure <| filter (not <. Text.null) (Text.lines (Text.pack out)) _ -> panic "git branch list failed" showFile :: FilePath -> Text -> FilePath -> IO (Maybe Text) 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.@?=) |
