Skip to content

Conversation

@Broderick-Westrope
Copy link

Closes #310. Please see the linked issue for more context on the goals of (and motivations for) this PR.
Duplicate of #311; I had some issues with GitHub account that deleted the forked repo :(

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 :)

@Broderick-Westrope
Copy link
Author

@caarlos0 could I get re-approval on this? It's a duplicate of #311 which closed due to some issues with my GitHub account that are now resolved.

@Broderick-Westrope
Copy link
Author

Hi @caarlos0, just bumping this one :)

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