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

Change chained hooks nil check to correct function #21

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

shivshav
Copy link
Contributor

@shivshav shivshav commented Dec 18, 2024

The nil check was incorrect, resulting in a panic if the following conditions hold true:

  1. You have a PostRead hook func defined
  2. You don't have a PostReadImmediate hook func defined
  3. You use ChainLifecycleHooks to use multiple hooks

PostRead --> PostReadImmediate

Additionally, a few other hook functions had what I believe are incorrect nil checks.

  • PreWrite: Was checking if PreProcessing was nil instead of PreWrite
  • PostFanout: Was check if PostRead was nil instead of PostFanout

`PostRead` --> `PostReadImmediate`
@shivshav shivshav marked this pull request as ready for review December 18, 2024 23:42
@stewartboyd119
Copy link
Member

Looks good. Do you mind adding a unit test in lifecycle_test.go. It can be really light. Just basically invoking a lifecycle method for a lifecycle struct constructed with the ChainedLifecycle method. The invocation not panicking is good enough. The test's godoc can explain the test's purpose (Since people will likely be confused why there aren't any more meaningful assertions).

@stewartboyd119
Copy link
Member

Actually. Nvm, I'll just merge and add the tests along with the changelog for version update

Copy link
Member

@stewartboyd119 stewartboyd119 left a comment

Choose a reason for hiding this comment

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

I'll go and add tests to protect against a ChainLifecycleHooks progression

@stewartboyd119 stewartboyd119 merged commit fe954c1 into zillow:main Dec 19, 2024
2 checks passed
@shivshav
Copy link
Contributor Author

Apologies I didn't see this earlier @stewartboyd119 thanks for merging this in and adding tests!

@shivshav shivshav deleted the fix/chained-postreadimmediate branch December 19, 2024 18:31
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