Skip to content

Remove testify/require dependency and use standard testing#5

Merged
kyleconroy merged 1 commit intomainfrom
claude/remove-testify-dependency-U8YHD
Apr 26, 2026
Merged

Remove testify/require dependency and use standard testing#5
kyleconroy merged 1 commit intomainfrom
claude/remove-testify-dependency-U8YHD

Conversation

@kyleconroy
Copy link
Copy Markdown
Contributor

This PR removes the github.com/stretchr/testify/require dependency from the codebase and replaces all assertion calls with standard Go testing patterns using reflect.DeepEqual() for equality checks and manual t.Fatal() calls for assertions.

Summary

The testify/require library has been completely removed as a dependency. All test files that previously used require.Equal(), require.True(), require.False(), require.NoError(), etc. have been refactored to use idiomatic Go testing with the standard testing package.

Key Changes

  • Removed github.com/stretchr/testify v1.8.4 from go.mod
  • Replaced all require.Equal(t, expected, actual) calls with reflect.DeepEqual() checks followed by t.Fatalf() on mismatch
  • Replaced require.True(t, condition) with if !condition { t.Fatal("expected true") }
  • Replaced require.False(t, condition) with if condition { t.Fatal("expected false") }
  • Replaced require.NoError(t, err) with if err != nil { t.Fatal(err) }
  • Replaced require.NotEmpty(t, value) with if len(value) == 0 { t.Fatal("expected non-empty") }
  • Added "reflect" imports to test files where needed
  • Reorganized import statements to follow Go conventions (standard library, then external packages)

Files Modified

Test files across multiple packages were updated:

  • types/field_type_test.go
  • parser/lexer_test.go, parser/digester_test.go, parser/lateral_test.go, parser/reserved_words_test.go, parser/consistent_test.go, parser/hintparser_test.go, parser/keywords_test.go
  • ast/util_test.go, ast/stats_test.go, ast/base_test.go, ast/dml_test.go, ast/model_test.go, ast/misc_test.go, ast/functions_test.go, ast/procedure_test.go, ast/flag_test.go, ast/format_test.go, ast/ddl_test.go, ast/expressions_test.go, ast/sem_test.go
  • mysql/privs_test.go, mysql/const_test.go, mysql/type_test.go, mysql/error_test.go
  • charset/charset_test.go, charset/encoding_test.go
  • auth/tidb_sm3_test.go, auth/caching_sha2_test.go, auth/mysql_native_password_test.go
  • terror/terror_test.go
  • format/format_test.go
  • duration/duration_test.go
  • util/escape_test.go
  • generate_keyword/genkeyword_test.go

Implementation Details

The refactoring maintains the same test logic and assertions while using only the Go standard library. Error messages follow a consistent pattern: "got %v, want %v" for equality assertions and descriptive messages for boolean checks.

https://claude.ai/code/session_01SzZiuen17CDNi8REpAGw1k

Replace github.com/stretchr/testify/require calls with the equivalent
stdlib testing patterns (if-cond t.Fatal/t.Fatalf). Use reflect.DeepEqual
for value comparisons that aren't directly comparable with ==.

https://claude.ai/code/session_01SzZiuen17CDNi8REpAGw1k
@kyleconroy kyleconroy merged commit f9c3aee into main Apr 26, 2026
1 check passed
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.

2 participants