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
export format property variables #347
Conversation
I also exported the |
I think the test failure is a flake
It passed on go 1.11.x and go 1.12.x |
Retriggered |
This makes sense to me but it would be great if we could get some test coverage on the change. |
I added some tests @williammartin @blgm - let me know if you'd like any changes |
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.
Hi @mitchdraft. Thank you for adding these tests. I've suggested a few small tweaks that I think makes them even better.
I notice that there aren't any tests around the limits for these values. For instance what happens when they are zero or negative? How do you feel about the risks around that? Are there some easy improvements that could be made? I see that MaxDepth
is defined as type uint
which means that it's impossible to set it to a negative value. Could a similar approach reduce risk here?
format/format_test.go
Outdated
}) | ||
}) | ||
|
||
Context("With alternate diff lengths", func() { |
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.
The context name is exactly the same as the previous test. I think it should be different and say something like with alternative number of characters to include around mismatch
.
format/format_test.go
Outdated
CharactersAroundMismatchToInclude = 10 | ||
Expect(MessageWithDiff(largeString, "to equal", smallString)).Should(Equal(expectedTruncatedStartSizeFailureMessageExtraDiff)) | ||
Expect(MessageWithDiff(smallString, "to equal", largeString)).Should(Equal(expectedTruncatedStartSizeSwappedFailureMessageExtraDiff)) | ||
CharactersAroundMismatchToInclude = initialValue |
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.
Other tests (the two above for example) set/unset things in a Before/AfterEach. It would be nice to match the style of the other tests as a file is easier to read and maintain if it follows a consistent style.
At the moment this test checks both the default and alternative behaviour. Perhaps the default testing should be left to the tests above, and this test should focus only on the alternative behaviour.
format/format_test.go
Outdated
}) | ||
|
||
Context("With alternate diff lengths", func() { | ||
It("long strings that differ only in length", func() { |
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.
Ideally BDD style tests should read as a sentence. For example the test above reads it should show the full diff
, and this one could read something like it shows more characters around a line length mismatch
- test names should describe the behaviour being tested rather than the implementation of the test.
thank you for the feedback @blgm, ready for another look |
Thank you @mitchdraft! |
sure thing! Would you mind making a new release @blgm? We've been looking forward to this feature and will use it immediately in our test utils https://github.com/solo-io/go-utils/blob/master/testutils/assertions.go#L25 |
Hi @mitchdraft, new release cut: https://github.com/onsi/gomega/releases/tag/v1.7.0 |
Thank you! |
Usually 5 characters of context around the diff location is enough, but it would be nice to be able to change that value as needed
#346