-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Unit test for github.com/uber-go/mock (#6)
- Loading branch information
1 parent
39f6d9f
commit 3285549
Showing
7 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package examples_test | ||
|
||
import ( | ||
"examples" | ||
"testing" | ||
|
||
"go.uber.org/mock/gomock" | ||
) | ||
|
||
func TestUberFinishCall(t *testing.T) { | ||
mock := gomock.NewController(t) | ||
mock.Finish() // want "calling Finish on gomock.Controller is no longer needed" | ||
} | ||
|
||
func TestUberFinishCallDefer(t *testing.T) { | ||
mock := gomock.NewController(t) | ||
defer mock.Finish() // want "calling Finish on gomock.Controller is no longer needed" | ||
} | ||
|
||
func TestUberFinishCallWithoutT(t *testing.T) { | ||
mock := gomock.NewController(nil) | ||
mock.Finish() // want "calling Finish on gomock.Controller is no longer needed" | ||
} | ||
|
||
func TestUberFinsihCallInAnotherFunction(t *testing.T) { | ||
mock := gomock.NewController(t) | ||
callUberFinish(mock) | ||
} | ||
|
||
func callUberFinish(mock *gomock.Controller) { | ||
mock.Finish() // want "calling Finish on gomock.Controller is no longer needed" | ||
} | ||
|
||
func TestUberNoFinishCall(t *testing.T) { | ||
gomock.NewController(t) | ||
} | ||
|
||
func TestUberFinishCallOther(t *testing.T) { | ||
mock := examples.New() | ||
mock.Finish() | ||
} |
35 changes: 35 additions & 0 deletions
35
pkg/analyzer/testdata/src/examples/uber_mock_renamed_pkg_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package examples_test | ||
|
||
import ( | ||
"testing" | ||
|
||
gomick "go.uber.org/mock/gomock" | ||
) | ||
|
||
func TestUberRenamedFinishCall(t *testing.T) { | ||
mock := gomick.NewController(t) | ||
mock.Finish() // want "calling Finish on gomock.Controller is no longer needed" | ||
} | ||
|
||
func TestUberRenamedFinishCallDefer(t *testing.T) { | ||
mock := gomick.NewController(t) | ||
defer mock.Finish() // want "calling Finish on gomock.Controller is no longer needed" | ||
} | ||
|
||
func TestUberRenamedFinishCallWithoutT(t *testing.T) { | ||
mock := gomick.NewController(nil) | ||
mock.Finish() // want "calling Finish on gomock.Controller is no longer needed" | ||
} | ||
|
||
func TestUberRenamedFinsihCallInAnotherFunction(t *testing.T) { | ||
mock := gomick.NewController(t) | ||
uberRenamedCallFinish(mock) | ||
} | ||
|
||
func uberRenamedCallFinish(mock *gomick.Controller) { | ||
mock.Finish() // want "calling Finish on gomock.Controller is no longer needed" | ||
} | ||
|
||
func TestUberRenamedNoFinishCall(t *testing.T) { | ||
gomick.NewController(t) | ||
} |