Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename WaitForOutput function #311

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Broderick-Westrope
Copy link

@Broderick-Westrope Broderick-Westrope commented Dec 25, 2024

Closes #310. Please see the linked issue for more context on the goals of (and motivations for) this PR.

Changes:

  • Rename existing WaitFor function to WaitForOutput to avoid confusion with the new, similarly named method.
  • Add msgbuffer type. This is a simple mutex-protected slice of tea.Msg.
  • Add msgCaptureModel type. Implements tea.Model. Contains a child tea.Model and a msgBuffer. Every tea.Msg is stored in the buffer before being sent to the child model.
  • Changes to NewTestModel so that the provided model is now wrapped in a msgCaptureModel.
    • Perhaps this could be disabled by default an enabled with a TestOption.
  • Add method TestModel WaitForMsg which takes a condition function and returns a tea.Msg. Much of the code for this was copied from the WaitFor function (now called WaitForOutput). At a set interval it will check the messages stored within the buffer and if any matches the provided condition function it will be returned.

Please note this is not a complete solution. Instead, this is intended to spark a discussion. I am happy to put in the required work to polish this off, but I want to make sure it is something that the Charm team wants in their repo before spending more time on it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat(teatest): add WaitForMsg function
1 participant