Skip to content

Add Expect.runExpectation#149

Merged
celsobonutti merged 9 commits intotrunkfrom
expectation-to-io
Jan 29, 2026
Merged

Add Expect.runExpectation#149
celsobonutti merged 9 commits intotrunkfrom
expectation-to-io

Conversation

@celsobonutti
Copy link
Member

This adds a new function Expect.runExpectation, which takes an Expectation and runs it into an IO. This is necessary for using the Llm.Test.Cached API from the llm-client library we now have.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new function Expect.runExpectation that allows running an Expectation directly in IO context. This functionality is needed to integrate with the Llm.Test.Cached API from the llm-client library.

Changes:

  • Added runExpectation function in Test.Internal that executes expectations in IO, returning results on success or throwing Failure exceptions on failure
  • Exported the new function through the Expect module
  • Added comprehensive test coverage for the new function

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.

File Description
nri-prelude/src/Test/Internal.hs Implements runExpectation function that converts expectations to IO actions, with proper error handling via exception throwing
nri-prelude/src/Expect.hs Exports the new runExpectation function in the public API
nri-prelude/tests/TestSpec.hs Adds test suite for runExpectation covering success and failure cases
nri-prelude/tests/golden-results-/test-report- Updates golden test files with adjusted line numbers due to test addition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
-- On success, returns the result. On failure, throws the Failure as an exception.
runExpectation :: Expectation' a -> Prelude.IO a
runExpectation expectation = do
log <- Platform.silentHandler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit worried about using silentHandler here. That will just not log anything that we do inside of our test setup which is probably not what we want.

Let's modify this function to take LogHandler as an argument and then use that logger for Task.perform.

Inside of withMocks we should be able to call Expect.succeeds Platform.logHandler to get the handler to use with runExpectation.

Copy link
Member

@micahhahn micahhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! LGTM

Copy link
Member

@micahhahn micahhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually hold on a second... this exception test wasn't exactly what I was thinking

Comment on lines 58 to 62
Internal.fromIO,
Internal.runExpectation,
Internal.fromIOResult,
Internal.Expectation',
around,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we will also need to expose Failure right?

Copy link
Member

@micahhahn micahhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, now we are looking good to merge

@celsobonutti celsobonutti added this pull request to the merge queue Jan 29, 2026
Merged via the queue into trunk with commit e3e78ce Jan 29, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants