refactor: rename WaitForOutput function #311
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #310. Please see the linked issue for more context on the goals of (and motivations for) this PR.
Changes:
WaitFor
function toWaitForOutput
to avoid confusion with the new, similarly named method.msgbuffer
type. This is a simple mutex-protected slice oftea.Msg
.msgCaptureModel
type. Implementstea.Model
. Contains a childtea.Model
and amsgBuffer
. Everytea.Msg
is stored in the buffer before being sent to the child model.NewTestModel
so that the provided model is now wrapped in amsgCaptureModel
.TestOption
.TestModel
WaitForMsg
which takes a condition function and returns atea.Msg
. Much of the code for this was copied from theWaitFor
function (now calledWaitForOutput
). 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 :)