Skip to content

Conversation

@Harsh-Daga
Copy link

@Harsh-Daga Harsh-Daga commented Jan 6, 2026

This PR migrates all test assertions from gotest.tools/v3/assert to github.com/stretchr/testify/assert, consolidating the codebase on a single testing library. The migration maintains full test coverage and behavior.

Implementation Details

Assertion Mapping:

  • assert.NilError(t, err) → assert.NoError(t, err)
  • assert.Assert(t, condition) → assert.True(t, condition)
  • assert.Check(t, condition) → assert.True(t, condition)
  • cmp.Equal(a, b) → assert.Equal(t, expected, actual)
  • cmp.Len(obj, n) → assert.Len(t, obj, n)
  • cmp.Contains(str, substr) → assert.Contains(t, str, substr)
  • cmp.DeepEqual(a, b) → assert.Equal(t, expected, actual) for simple cases

Complex Comparisons:
For tests requiring cmpopts (specifically helpers_test.go), I retained google/go-cmp directly and used assert.Empty(t, cmp.Diff(expected, actual, opts)) pattern. This preserves the powerful comparison options needed for complex struct comparisons while still using testify for the assertion.

Files Migrated (24 total):

Command packages:

  • cmd/gen-source-variants/main_test.go
  • cmd/test2json2gha/event_test.go
  • cmd/test2json2gha/github_test.go
  • cmd/test2json2gha/main_test.go
  • cmd/test2json2gha/summary_test.go

Root level:

  • helpers_test.go
  • load_test.go
  • source_test.go
  • spec_test.go

Package tests:

  • linters/yaml_json_tags_test.go
  • packaging/linux/deb/template_rules_test.go
  • packaging/linux/rpm/template_test.go
  • sessionutil/socketprovider/proxy_test.go

Test directory:

  • test/cache_test.go
  • test/handlers_test.go
  • test/helpers_test.go
  • test/linux_target_test.go
  • test/network_test.go
  • test/signing_test.go
  • test/source_test.go
  • test/windows_test.go

Test utilities:

  • test/testenv/buildx.go

Testing

All existing tests continue to pass with the new assertions:

go test -short ./...

Build verification:
go build ./...

I verified that:

  1. All test files compile without errors
  2. All existing test cases pass with identical behavior
  3. No test logic was changed, only assertion syntax
  4. Dependencies were properly cleaned up with go mod tidy

Notes

  • gotest.tools/v3/skip is intentionally retained in some test files as testify does not provide equivalent skip functionality
  • The gotest.tools/v3 dependency remains in go.mod solely for the skip package usage
  • Test behavior is unchanged; this is purely a syntactic migration
  • Argument order in assert.Equal follows testify convention: assert.Equal(t, expected, actual)

Fixes #913

Copy link
Contributor

@invidian invidian left a comment

Choose a reason for hiding this comment

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

@Harsh-Daga Assert from gotest.tools/v3/assert will FailNow() the tests, so we should actually use github.com/stretchr/testify/require to preserve that behaviour.

Sign up for free to 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.

Convert from gotest.tools/v3/assert -> testify

2 participants