Refactor: Replace assert.EqualError() in tests with assert.ErrorIs()
Currently, many tests in the codebase use assert.EqualError() to verify error messages through direct string comparison. For example, in repository_files_test:
fi, resp, err = client.RepositoryFiles.CreateFile(13083, "app/project.rb", nil, errorOption)
assert.EqualError(t, err, "RequestOptionFunc returns an error")
assert.Nil(t, resp)
assert.Nil(t, fi)
There are currently 100+ such cases across the codebase.
Issues with this approach:
Brittle: Tests break when error messages change, even if the underlying error condition remains the same.
Harder to maintain: Error strings must be kept in sync between implementation and tests.
Limited support for error wrapping: assert.EqualError does not work well with Go’s fmt.Errorf("%w", err) pattern
I suggest replacing string-based error assertions with type-based checks using assert.ErrorIs() and type assertions via errors.As(). I'd be glad to contribute this improvement, at least with the tests in the RepositoryFilesService.