-
Notifications
You must be signed in to change notification settings - Fork 13
Replace gopkg.in/check.v1 with the standard testing library #52
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
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.
Pull Request Overview
This PR removes the dependency on gopkg.in/check.v1
and converts all existing test suites to use Go’s standard testing
package, preserving test logic and adding subtests or reflect.DeepEqual
/regexp
‐based assertions.
- Deleted the legacy
suite_test.go
and go-check suite boilerplate. - Updated multiple
*_test.go
files to replace GoCheck assertions withtesting.T
methods andreflect.DeepEqual
/regexp
checks. - Cleaned up
go.mod
by removing the GoCheck requirement.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
suite_test.go | Removed GoCheck suite setup (no longer needed). |
node_test.go | Converted node tests to use testing.T , reflect.DeepEqual , regexp . |
limit_test.go | Switched limit tests to testing.T and regexp , removed GoCheck. |
encode_test.go | Migrated encoding tests to testing.T , added subtests. |
decode_test.go | Migrated decoding tests to testing.T , added subtests. |
go.mod | Removed gopkg.in/check.v1 from module requirements. |
Comments suppressed due to low confidence (4)
encode_test.go:515
- The
fmt.Sprintf
call is used here butfmt
is not imported; addimport "fmt"
to the import block.
t.Run(fmt.Sprintf("test %d: %q", i, item.data), func(t *testing.T) {
decode_test.go:870
- The
fmt.Sprintf
call is used here butfmt
is not imported; addimport "fmt"
to the import block.
t.Run(fmt.Sprintf("test %d: %q", i, item.data), func(t *testing.T) {
decode_test.go:1954
bytes.NewBuffer
is used here butbytes
is not imported; addimport "bytes"
to the import block.
dec := yaml.NewDecoder(bytes.NewBuffer([]byte(item.data)))
limit_test.go:43
- [nitpick] Instead of
return
to skip short tests, callt.Skip("skipping long test in short mode")
so the test is marked as skipped.
}
2600377
to
767f266
Compare
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.
I raised a few things, but LGTM 👍
Thanks for working on this
That's why the whole thing felt so odd. I've also made good experience with if err != nil {
t.Fatalf("Close() returned error: %v", err)
} then becomes require.NoError(t, err, "Close() returned error: %v", err) or simply require.NoError(t, err, "Close() returned error") |
@andig I'm unsure what you meant. The way it sounds to me is "okay, but it was simpler with testify and I'm used to it." While I agree, it doesn't sound logic to me. Dolmen and @brackendawson testify maintainers asked yaml project to do not depends on testify because testify depends itself on (the old) yaml project. The idea is to avoid cyclic dependencies.
So testify cannot be used. Here I don't see a problem with this PR. A few files are updated, yes, it's not as simple as testify, yes, it is using vanilla testing. But I would say it's expected because:
If there is a huge problem, nothing prevents to add a internal wrapper library that could check:
And report test failure message returning the expected state. It's easy. It can be extended if needed. But this would be a NIH logic, BTW Bracken suggested to use I feel like having a few wrappers could be considered, if vanilla become a problem. This is the reply I'm doing about what I understood you say. But as I said, I might have misunderstood what you meant. So please apologize myself if I'm wrong and my reply is pointless. |
Sorry, I wasn‘t aware of that. I‘m confused by how that would be a bad thing for tests, but that‘s OT. No concerns, sorry for the noise. |
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.
LGTM
PS. We should be using t.Setenv
but this can come later in a different PR.
767f266
to
668d0a0
Compare
This looks good enough to merge. We can apply the optimization ideas in further PRs. |
closes #21