-
-
Notifications
You must be signed in to change notification settings - Fork 3
[STREAM-689] Use Builder for InflightActivation
#523
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
Conversation
|
Since the new builder boilerplate takes around 150 lines, these changes remove nearly 300 lines from the tests overall. We could cut even more code by...
|
markstory
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. This should make writing tests simpler.
markstory
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work 👏
…eorge/activation-builder
InflightActivationInflightActivation
Description
Right now, every
InflightActivationin the unit tests is constructed manually field by field. This is extremely verbose and largely unnecessary, as most fields are set to use default values (for example, 0 when the type is an integer orNonewhen the type is anOption).We can reduce this boilerplate by using the builder pattern to construct these structs instead. That way, you only need to set the fields you are interested in, and it's easier to tell what's different between two
InflightActivations as you don't need to parse a million irrelevant fields that are all the same.For a demonstration, consider the two activations A and B below. What's the difference between them?
Activation A
Activation B
Activation A has an offset of 0 while B has an offset of 10. Even if it didn't take very long to figure that out, you still had to read quite a few irrelevant fields that are the same between both activations.
Now consider the same two activations constructed using a builder. We don't need to read all the fields because only the
offsetsetter is used! This tells us almost immediately that the offset is the only value that differs between the two tasks.Activation A
Activation B
As a result, it should be easier to write, read, and understand tests.
Details
derive_buildercrate to generate a builder forInflightActivationwith reasonable defaultsTaskActivationsince it's generated bysentry-protosInflightActivation { ... }in the tests with the builder