Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: rewrite tests to use testify instead of goconvey #300

Merged
merged 1 commit into from Sep 15, 2021
Merged

all: rewrite tests to use testify instead of goconvey #300

merged 1 commit into from Sep 15, 2021

Conversation

sagikazarmark
Copy link
Contributor

What problem should be fixed?

Fixes #295

Have you added test cases to catch the problem?

This PR is about refactoring tests, no additional tests are necessary.

Notes for reviewer

This is an attempt to refactor tests into using testify instead of goconvey.

During the refactor I followed the following rules:

  • Singular top level Convey was removed everywhere
  • Multiple Convey blocks were converted into subtests (t.Run)
  • Child Convey blocks were converted into subtests (t.Run)
  • require was used everywhere when the following assertions depended on the outcome (eg. no error or no nil return value)
  • assert was used everywhere else

I suggest turning off showing whitespaces in the diff because there are lots of indentation changes.

If you like the result, I can refactor the remaining tests as well.

@sagikazarmark sagikazarmark marked this pull request as draft September 7, 2021 12:49
@gandarez
Copy link
Contributor

gandarez commented Sep 7, 2021

+1

@sagikazarmark
Copy link
Contributor Author

@unknwon Please let me know if you think this is the right path. If so, I can finish the PR.

Copy link
Member

@unknwon unknwon left a comment

Choose a reason for hiding this comment

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

Thank you for taking on this effort! LGTM

helper_test.go Outdated Show resolved Hide resolved
file_test.go Show resolved Hide resolved
@sagikazarmark sagikazarmark marked this pull request as ready for review September 9, 2021 21:31
@sagikazarmark
Copy link
Contributor Author

@unknwon I finished the PR, please take a look.

@sagikazarmark
Copy link
Contributor Author

@unknwon Ping :)

Would be nice to get this merged before other PRs start conflicting with it....it's a pretty big diff.

@codecov
Copy link

codecov bot commented Sep 15, 2021

Codecov Report

Merging #300 (2b2ada5) into main (326d24f) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #300   +/-   ##
=======================================
  Coverage   88.11%   88.11%           
=======================================
  Files           9        9           
  Lines        1355     1355           
=======================================
  Hits         1194     1194           
  Misses         98       98           
  Partials       63       63           

file_test.go Outdated
Comment on lines 24 to 26
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"

Comment on lines 9 to 11
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"

ini_test.go Outdated
Comment on lines 24 to 26
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"
"github.com/stretchr/testify/require"
"gopkg.in/ini.v1"

ini_test.go Outdated
So(err, ShouldBeNil)
So(f, ShouldNotBeNil)
require.NoError(t, err)
assert.NotNil(t, f)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert.NotNil(t, f)
require.NotNil(t, f)

ini_test.go Outdated
So(err, ShouldBeNil)
So(f, ShouldNotBeNil)
require.NoError(t, err)
assert.NotNil(t, f)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert.NotNil(t, f)
require.NotNil(t, f)

ini_test.go Outdated
t.Run("inverse case", func(t *testing.T) {
f, err := ini.LoadSources(ini.LoadOptions{AllowPythonMultilineValues: true}, minimalConf)
require.NoError(t, err)
assert.NotNil(t, f)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert.NotNil(t, f)
require.NotNil(t, f)

ini_test.go Outdated
t.Run("insensitive to sections and sensitive to key names", func(t *testing.T) {
f, err := ini.LoadSources(ini.LoadOptions{InsensitiveSections: true}, minimalConf)
require.NoError(t, err)
assert.NotNil(t, f)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert.NotNil(t, f)
require.NotNil(t, f)

ini_test.go Outdated
t.Run("sensitive to sections and insensitive to key names", func(t *testing.T) {
f, err := ini.LoadSources(ini.LoadOptions{InsensitiveKeys: true}, minimalConf)
require.NoError(t, err)
assert.NotNil(t, f)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert.NotNil(t, f)
require.NotNil(t, f)

ini_test.go Outdated
t.Run("inverse case", func(t *testing.T) {
f, err := ini.LoadSources(ini.LoadOptions{}, minimalConf)
require.NoError(t, err)
assert.NotNil(t, f)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert.NotNil(t, f)
require.NotNil(t, f)

ini_test.go Outdated
So(err, ShouldBeNil)
So(f, ShouldNotBeNil)
require.NoError(t, err)
assert.NotNil(t, f)
Copy link
Member

Choose a reason for hiding this comment

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

Same as every other place.

@unknwon
Copy link
Member

unknwon commented Sep 15, 2021

Thanks, lint is failing BTW.

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
@sagikazarmark
Copy link
Contributor Author

Thanks for the review @unknwon ! Should be good now.

@unknwon unknwon changed the title Rewrite tests to use testify instead of goconvey all: rewrite tests to use testify instead of goconvey Sep 15, 2021
Copy link
Member

@unknwon unknwon left a comment

Choose a reason for hiding this comment

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

Thank you!

@sagikazarmark
Copy link
Contributor Author

Breaking lint job seems unrelated. I think it's mostly because go modules (or lack thereof). Happy to take a look at it in a followup PR.

@unknwon
Copy link
Member

unknwon commented Sep 15, 2021

There is one valid lint error

Error: File is not `gofmt`-ed with `-s` (gofmt)`

but the golangci GitHub Action is playing smart to not tell us which file it is.

@unknwon
Copy link
Member

unknwon commented Sep 15, 2021

OK, looks like that's a file somewhere on main, not related to this PR, merging!

@unknwon unknwon merged commit bba62c3 into go-ini:main Sep 15, 2021
@sagikazarmark sagikazarmark deleted the testify branch September 15, 2021 16:07
@sagikazarmark
Copy link
Contributor Author

Do you think you could tag a new version as well?

@unknwon
Copy link
Member

unknwon commented Sep 15, 2021

Here you go: https://github.com/go-ini/ini/releases/tag/v1.63.1

@sagikazarmark
Copy link
Contributor Author

Thank you!

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.

github.com/smartystreets/goconvey v1.6.4 // indirect
3 participants