Skip to content

fix mixed assertion libraries in tests - #13689

Merged
glours merged 1 commit into
docker:mainfrom
thaJeztah:unify_asserts
Mar 31, 2026
Merged

fix mixed assertion libraries in tests#13689
glours merged 1 commit into
docker:mainfrom
thaJeztah:unify_asserts

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

Before this, assertion libraries were mixed, sometimes even in the same file.

git grep -l '"gotest.tools/v3/' | wc -l
75
git grep -l '"github.com/stretchr/testify' | wc -l
24

What I did

Related issue

(not mandatory) A picture of a cute animal, if possible in relation to what you did

@thaJeztah
thaJeztahforce-pushed the unify_asserts branch 7 times, most recently from 2b7112a to 0344090CompareMarch 30, 2026 15:35
@codecov

codecovBot commented Mar 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
pkg/utils/safebuffer.go0.00%8 Missing ⚠️

📢 Thoughts on this report? Let us know!

Comment on lines -67 to +84
require.Eventuallyf(t, func() bool {
poll.WaitOn(t, func(logt poll.LogT) poll.Result {
bufContents.Reset()
b.m.Lock()
defer b.m.Unlock()
if _, err := b.b.WriteTo(&bufContents); err != nil {
require.FailNowf(t, "Failed to copy from buffer",
"Error: %v", err)
return poll.Error(fmt.Errorf("failed to copy from buffer. Error: %w", err))
}
return strings.Contains(bufContents.String(), v)
}, 2*time.Second, 20*time.Millisecond,
"Buffer did not contain %q\n============\n%s\n============",
v, &bufContents)
if !strings.Contains(bufContents.String(), v) {
return poll.Continue(
"buffer does not contain %q\n============\n%s\n============",
v, &bufContents)
}
return poll.Success()
},
poll.WithTimeout(2*time.Second),
poll.WithDelay(20*time.Millisecond),
)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

CodeCov is complaining about a test-utility, but probably doesn't ignore it, because it's not in a _test.go

Before this, assertion libraries were mixed, sometimes
even in the same file.
git grep -l '"gotest.tools/v3/' | wc -l
75
git grep -l '"github.com/stretchr/testify' | wc -l
24
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
thaJeztah marked this pull request as ready for review March 31, 2026 15:11
@thaJeztah
thaJeztah requested a review from a team as a code ownerMarch 31, 2026 15:11

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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 standardizes the Go test assertion library usage across the repository by migrating tests away from stretchr/testify to gotest.tools/v3/assert, and tightens lint enforcement to prevent reintroducing testify.

Changes:

  • Replace testify/assert + testify/require usages in multiple unit/e2e tests with gotest.tools/v3/assert (and assert/cmp where needed).
  • Remove github.com/stretchr/testify from go.mod and add golangci-lint forbidigo rules to forbid testify imports going forward.
  • Adjust a few tests that depended on testify-specific helpers (e.g., element matching) by sorting or switching to deep-equality/regex comparisons.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
pkg/watch/watcher_naive_test.goSwitch require assertions to gotest.tools assert.NilError.
pkg/watch/paths_test.goSwitch to gotest.tools asserts; update Windows path literal; use ErrorContains.
pkg/watch/notify_test.goReplace testify asserts with gotest.tools equivalents.
pkg/watch/ephemeral_test.goReplace testify formatting assertions with gotest.tools NilError/Assert.
pkg/utils/set_test.goReplace testify checks; sort set elements before deep-equality where needed.
pkg/utils/safebuffer.goReplace require.Eventuallyf with poll.WaitOn for eventual assertions.
pkg/e2e/watch_test.goReplace require usage with assert.NilError.
pkg/e2e/up_test.goReplace require usage with gotest.tools assertions.
pkg/e2e/start_stop_test.goReplace testify regex assertions with gotest.tools assert/cmp regex comparison.
pkg/e2e/scale_test.goRemove testify failure helper usage; fail via t.Fatalf.
pkg/e2e/restart_test.goReplace testify regex assertions with gotest.tools assert/cmp.
pkg/e2e/ps_test.goReplace testify assert/require with gotest.tools asserts + assert/cmp.
pkg/e2e/pause_test.goReplace require usage; add extra error-type assertion for network error.
pkg/e2e/networks_test.goReplace strings.Contains assertion with gotest.tools is.Contains.
pkg/e2e/framework.goReplace require usage with gotest.tools (and t.Fatal in one spot).
pkg/e2e/compose_test.goReplace testify regex assertion with gotest.tools assert/cmp.
pkg/e2e/build_test.goReplace require usage with gotest.tools assert/cmp contains.
pkg/e2e/assert.goReplace require usage with gotest.tools assertions + assert/cmp.
pkg/compose/watch_test.goReplace ElementsMatch with deterministic sort + assert.DeepEqual.
pkg/compose/viz_test.goReplace testify assertions with gotest.tools asserts + assert/cmp.
pkg/compose/logs_test.goReplace testify assertions with gotest.tools asserts + assert/cmp.
pkg/compose/loader_test.goReplace testify assertions with gotest.tools asserts + assert/cmp.
pkg/compose/dependencies_test.goReplace testify assertions with gotest.tools asserts + assert/cmp.
internal/tracing/tracing_test.goReplace require with gotest.tools assertions.
internal/tracing/attributes_test.goReplace require with gotest.tools assertions.
internal/desktop/client_test.goReplace require with gotest.tools assertions.
cmd/compose/viz_test.goReplace testify assertions with gotest.tools asserts; adjust error expectation.
cmd/compose/top_test.goReplace testify assertions with gotest.tools deep-equality and NilError.
cmd/compose/options_test.goReplace require assertions with gotest.tools assertions.
go.modRemove testify (and related indirect deps) from module requirements.
.golangci.ymlAdd forbidigo rules to forbid testify imports (assert/require/suite).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpkg/e2e/framework.go

src, err := os.Open(sourceFile)
require.NoError(t, err, "Failed to open source file: %s")
assert.NilError(t, err, "Failed to open source file: %s")

CopilotAIMar 31, 2026

Copy link

Choose a reason for hiding this comment

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

The failure message uses a %s format verb but no argument is provided, so the output will show a formatting "(MISSING)" placeholder. Pass sourceFile as the formatting argument (or remove the verb) so the error message is meaningful.

Suggested change
assert.NilError(t, err, "Failed to open source file: %s")
assert.NilError(t, err, "Failed to open source file: %s", sourceFile)

Copilot uses AI. Check for mistakes.
Comment threadgo.mod
Comment on lines 43 to 48
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
github.com/tilt-dev/fsnotify v1.4.8-0.20220602155310-fff9c274a375
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0
go.opentelemetry.io/otel v1.42.0

CopilotAIMar 31, 2026

Copy link

Choose a reason for hiding this comment

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

go.mod removes github.com/stretchr/testify (and related indirect deps), but go.sum is not updated in this PR. The repo's vendor-validate target runs go mod tidy and fails if go.sum differs, so please run make go-mod-tidy (or go mod tidy) and commit the resulting go.sum changes.

Copilot uses AI. Check for mistakes.
@glours
glours merged commit 92a7ac1 into docker:mainMar 31, 2026
47 of 48 checks passed
@thaJeztah
thaJeztah deleted the unify_asserts branch March 31, 2026 16:47
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Apr 10, 2026
This MR contains the following updates:
| Package | Update | Change |
|---|---|---|
| [docker/compose](https://github.com/docker/compose) | patch | `v5.1.1` → `v5.1.2` |
MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).
**Proposed changes to behavior should be submitted there as MRs.**
---
### Release Notes
<details>
<summary>docker/compose (docker/compose)</summary>
### [`v5.1.2`](https://github.com/docker/compose/releases/tag/v5.1.2)
[Compare Source](docker/compose@v5.1.1...v5.1.2)
#### What's Changed
##### 🐛 Fixes
- Fix TTY timer rendering when duration length changes by [@&#8203;MaybeSam05](https://github.com/MaybeSam05) in [#&#8203;13634](docker/compose#13634)
- Fix up attach filtering by [@&#8203;false200](https://github.com/false200) in [#&#8203;13664](docker/compose#13664)
- Preserve ssh:// URL scheme when resolving Dockerfile path by [@&#8203;ssam18](https://github.com/ssam18) in [#&#8203;13669](docker/compose#13669)
- Initialize and pass envFiles map in processExtends by [@&#8203;Mohamed-Moumni](https://github.com/Mohamed-Moumni) in [#&#8203;13678](docker/compose#13678)
- Fix TestRunHook\_ConsoleSize on macOS by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13686](docker/compose#13686)
- Restore post-connect fallback for multi-network stacks on API < 1.44 by [@&#8203;jotka](https://github.com/jotka) in [#&#8203;13629](docker/compose#13629)
- Publish: return api.ErrCanceled when user declines interactive prompts by [@&#8203;ishwar170695](https://github.com/ishwar170695) in [#&#8203;13674](docker/compose#13674)
- Return error on non-ErrNotExist stat failures in Tar.Sync() by [@&#8203;Lidang-Jiang](https://github.com/Lidang-Jiang) in [#&#8203;13684](docker/compose#13684)
##### 🔧 Internal
- Refactor: thread context through publish sensitive data check by [@&#8203;ishwar170695](https://github.com/ishwar170695) in [#&#8203;13653](docker/compose#13653)
- Add AI-powered MR review workflow via `docker/cagent-action` by [@&#8203;glours](https://github.com/glours) in [#&#8203;13659](docker/compose#13659)
- Update `cagent-action` to latest (with better permissions) by [@&#8203;derekmisler](https://github.com/derekmisler) in [#&#8203;13665](docker/compose#13665)
- Pin GitHub Actions to commit SHA, remove pr-review workflow by [@&#8203;glours](https://github.com/glours) in [#&#8203;13662](docker/compose#13662)
- Exclude hook\_test.go from Windows builds and propagate ExecStart error in runWaitExec by [@&#8203;pawannn](https://github.com/pawannn) in [#&#8203;13683](docker/compose#13683)
- Skip MR review workflow for Dependabot MRs by [@&#8203;glours](https://github.com/glours) in [#&#8203;13679](docker/compose#13679)
- Use negotiated API version for network setup by [@&#8203;glours](https://github.com/glours) in [#&#8203;13690](docker/compose#13690)
- Fix mixed assertion libraries in tests by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13689](docker/compose#13689)
- Test: use random host port for dind TLS build test by [@&#8203;ricardobranco777](https://github.com/ricardobranco777) in [#&#8203;13630](docker/compose#13630)
- Remove direct dependency on `docker/docker` by [@&#8203;glours](https://github.com/glours) in [#&#8203;13706](docker/compose#13706)
##### ⚙️ Dependencies
- Bump github.com/containerd/platforms from `1.0.0-rc.2` to `1.0.0-rc.3` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13657](docker/compose#13657)
- Bump golangci-lint to `v2.11.3` and configure CLAUDE to use it on change by [@&#8203;ndeloof](https://github.com/ndeloof) in [#&#8203;13656](docker/compose#13656)
- Bump google.golang.org/grpc from `1.78.0` to `1.79.3` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13642](docker/compose#13642)
- Bump github.com/moby/patternmatcher from `0.6.0` to `0.6.1` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13667](docker/compose#13667)
- Bump go.opentelemetry.io/otel/sdk from `1.39.0` to `1.42.0` by [@&#8203;glours](https://github.com/glours) in [#&#8203;13663](docker/compose#13663)
- Bump github.com/docker/cli from `29.2.1+incompatible` to `29.3.1+incompatible` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13670](docker/compose#13670)
- Bump github.com/hashicorp/go-version from `1.8.0` to `1.9.0` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13692](docker/compose#13692)
- Bump github.com/docker/buildx `v0.33.0`, buildkit `v0.29.0` by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13693](docker/compose#13693)
- Bump google.golang.org/grpc from `1.79.3` to `1.80.0` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13697](docker/compose#13697)
- Bump github.com/containerd/platforms from `1.0.0-rc.3` to `1.0.0-rc.4` by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;13696](docker/compose#13696)
- Bump github.com/moby/moby/client `v0.4.0`, moby/api `v1.54.1` by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13708](docker/compose#13708)
- Bump github.com/docker/cli `v29.4.0` by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13707](docker/compose#13707)
- Bump compose-go to version `v2.10.2` by [@&#8203;glours](https://github.com/glours) in [#&#8203;13705](docker/compose#13705)
- Bump to Go `1.25.9` by [@&#8203;thaJeztah](https://github.com/thaJeztah) in [#&#8203;13720](docker/compose#13720)
#### New Contributors
- [@&#8203;MaybeSam05](https://github.com/MaybeSam05) made their first contribution in [#&#8203;13634](docker/compose#13634)
- [@&#8203;ishwar170695](https://github.com/ishwar170695) made their first contribution in [#&#8203;13653](docker/compose#13653)
- [@&#8203;derekmisler](https://github.com/derekmisler) made their first contribution in [#&#8203;13665](docker/compose#13665)
- [@&#8203;false200](https://github.com/false200) made their first contribution in [#&#8203;13664](docker/compose#13664)
- [@&#8203;ssam18](https://github.com/ssam18) made their first contribution in [#&#8203;13669](docker/compose#13669)
- [@&#8203;Mohamed-Moumni](https://github.com/Mohamed-Moumni) made their first contribution in [#&#8203;13678](docker/compose#13678)
- [@&#8203;pawannn](https://github.com/pawannn) made their first contribution in [#&#8203;13683](docker/compose#13683)
- [@&#8203;jotka](https://github.com/jotka) made their first contribution in [#&#8203;13629](docker/compose#13629)
- [@&#8203;Lidang-Jiang](https://github.com/Lidang-Jiang) made their first contribution in [#&#8203;13684](docker/compose#13684)
**Full Changelog**: <docker/compose@v5.1.1...v5.1.2>
</details>
---
### Configuration
📅 **Schedule**: (UTC)
- Branch creation
- At any time (no schedule defined)
- Automerge
- At any time (no schedule defined)
🚦 **Automerge**: Enabled.
♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.
🔕 **Ignore**: Close this MR and you won't be reminded about this update again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box
---
This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMTAuOCIsInVwZGF0ZWRJblZlciI6IjQzLjExMC44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6cGF0Y2giXX0=-->
Sign up for freeto 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.

3 participants

@thaJeztah@glours