linkerd / linkerd/linkerd2-conformance
refactor `gomega` assertions
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 1
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
### Problem
Currently, we're making use of [Gomega](https://onsi.github.io/gomega/) as a matcher library with [Ginkgo](https://onsi.github.io/ginkgo/), for making assertions in the tests. An example of such an assertion would be:
```go
func testSomething() {
err := doSomething()
gomega.Expect(err).Should(gomega.BeNil(), fmt.Sprint("failed to do something: %s", err.Error()))
}
```
The problem with using these directly in the tests would be that contributors now have to deal with learning the Gomega syntax for assertions, and also having too many of these look ugly and make the code less readable.
### Solution
We could create reusable helper functions that essentially act as wrappers around these assertions. For example
```go
func ExpectNil(item interface{}. annotation string) {
gomega.Expect(err).Should(gomega.BeNil(), message)
}
func testSomething() {
err := doSomething()
utils.ExpectNil(err, fmt.Sprintf("failed to do something: %s", err.Error()))
}
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing Gomega assertions in the test suite and review how Ginkgo tests currently report failures. Use the proposed reusable assertion wrappers as the scope, then update applicable tests and run the existing test suite to confirm behavior and readable failure messages remain intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- testing-qa
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100