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

Add help text to explain why hooks do not run #56

Merged
merged 1 commit into from
Jun 12, 2019

Conversation

timClicks
Copy link

@timClicks timClicks commented Jun 12, 2019

This PR provides some more context to unassuming new developers who are learning about BeforeHooks/AfterHooks.

Using check's comment feature, this message is displayed:

// At least one hook has not run. Some common causes:
    // - forgetting to prefix the call to Check() with defer
    // - checks in the build function failing, so the slice of txn.Ops never gets run
    // - miscalculating the number of hooks and/or attempts
    c.Assert(remaining, gc.HasLen, 0)
	... obtained []txn.TestHook = []txn.TestHook{txn.TestHook{Before:(func())(0x2f78a10), After:(func())(0x2f78bb0)}, txn.TestHook{Before:(func())(0x2f78a10), After:(func())(0x2f78bb0)}, txn.TestHook{Before:(func())(0x2f78a10), After:(func())(0x2f78bb0)}}
... n int = 0

Hopefully this is more useful to newcomers than the bald Assert failure:

c.Assert(remaining, gc.HasLen, 0)
... obtained []txn.TestHook = []txn.TestHook{txn.TestHook{Before:(func())(0x2f78a10), After:(func())(0x2f78bb0)}, txn.TestHook{Before:(func())(0x2f78a10), After:(func())(0x2f78bb0)}, txn.TestHook{Before:(func())(0x2f78a10), After:(func())(0x2f78bb0)}}
... n int = 0

Copy link

@babbageclunk babbageclunk left a comment

Choose a reason for hiding this comment

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

Looks great, assuming the comment gets displayed nicely in the output!

// At least one hook has not run. Some common causes:
//
// - forgetting to prefix the call to Check() with defer
// - business logic never succeeding, meaning the transaction operations are never invoked

Choose a reason for hiding this comment

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

Maybe this wording for point 2?

- checks in the build function failing, so the slice of txn.Ops never gets run

Just to make it more concrete where to look for the problem.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@timClicks timClicks force-pushed the add-hook-failure-help branch from 30c2b9e to cb6047e Compare June 12, 2019 23:30
@timClicks
Copy link
Author

$$merge$$

@babbageclunk
Copy link

!!build!!

@babbageclunk
Copy link

$$merge$$

@jujubot jujubot merged commit afeb83d into juju:master Jun 12, 2019
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.

3 participants