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

scripttest: Pass testing.TB to newEngine #21

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Oct 11, 2024

To allow cleaning up resources after the test terminates, pass the testing.TB to the newEngine function.

This is needed to be able to stop the hive in a test:

  scripttest.Test(...,
    func(t testing.TB) *script.Engine {
      h := hive.New(Thing)
      require.NoError(t, h.Start(...))
      t.Cleanup(func() {
       assert.NoError(t, h.Stop(...))
      })
      return &script.Engine{...}
    }, ...)

To allow cleaning up resources after the test terminates,
pass the testing.TB to the newEngine function.

This is needed to be able to stop the hive in a test:

  scripttest.Test(...,
    func(t testing.TB) *script.Engine {
      h := hive.New(Thing)
      require.NoError(t, h.Start(...))
      t.Cleanup(func() {
       assert.NoError(t, h.Stop(...))
      })
      return &script.Engine{...}
    }, ...)

Signed-off-by: Jussi Maki <[email protected]>
@joamaki joamaki requested a review from a team as a code owner October 11, 2024 10:23
Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@joamaki joamaki merged commit bb8f3c0 into main Oct 21, 2024
1 check passed
@joamaki joamaki deleted the pr/joamaki/hivescript-pass-testingt branch October 21, 2024 11:37
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.

2 participants