Skip to content

integration-cli: remove unneeded sprintf's in asserts #39902

Merged
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:remove_unneeded_sprintfs
Sep 11, 2019
Merged

integration-cli: remove unneeded sprintf's in asserts #39902
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:remove_unneeded_sprintfs

Conversation

@thaJeztah
Copy link
Member

Follow-up to #39799 #39799 (comment)

the fmt.Sprintf(..) is not needed, assert.Equal() already takes a format-string;

func Equal(t TestingT, x, y interface{}, msgAndArgs ...interface{}) {

func TestFoo(t *testing.T) {
	assert.Equal(t, "one", "two", "bla %s bla", "bla")
}
=== RUN   TestFoo
--- FAIL: TestFoo (0.00s)
    debug_test.go:48: assertion failed: one (string) != two (string): bla bla bla
FAIL

Process finished with exit code 1

Replaced using a bit of grep-ing;

find . -name "*_test.go" -exec sed -E -i 's#assert.Assert\((.*), fmt.Sprintf\((.*)\)\)$#assert.Assert\(\1, \2\)#g' '{}' \;

@thaJeztah
Copy link
Member Author

ping @tiborvass @vdemeester @kolyshkin PTAL

@thaJeztah
Copy link
Member Author

whoops, need to remove some imports

@thaJeztah thaJeztah force-pushed the remove_unneeded_sprintfs branch from 529adce to b22ab6d Compare September 11, 2019 11:26
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah force-pushed the remove_unneeded_sprintfs branch from b22ab6d to 943fd15 Compare September 11, 2019 11:39
@thaJeztah
Copy link
Member Author

looks like I missed one; pushed again 🤞(sorry 🤗 hope it's good now)

@thaJeztah thaJeztah force-pushed the remove_unneeded_sprintfs branch 4 times, most recently from 3dc4c7a to aeee65a Compare September 11, 2019 13:55
Replaced using a bit of grep-ing;

```
find . -name "*_test.go" -exec sed -E -i 's#assert.Assert\((.*), fmt.Sprintf\((.*)\)\)$#assert.Assert\(\1, \2\)#g' '{}' \;
```

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the remove_unneeded_sprintfs branch from aeee65a to 0fabf3e Compare September 11, 2019 14:18
@cpuguy83 cpuguy83 merged commit 34ffb79 into moby:master Sep 11, 2019
@thaJeztah thaJeztah deleted the remove_unneeded_sprintfs branch September 11, 2019 16:59
@thaJeztah thaJeztah added this to the 20.03.0 milestone Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants