-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new expressions to allowed types (#863)
- Loading branch information
1 parent
13d696b
commit ede4f2c
Showing
8 changed files
with
248 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package iface_new_type_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/vektra/mockery/v2/pkg" | ||
) | ||
|
||
func TestParsing(t *testing.T) { | ||
parser := pkg.NewParser(nil) | ||
ctx := context.Background() | ||
require.NoError(t, parser.ParsePackages(ctx, []string{"github.com/vektra/mockery/v2/pkg/fixtures/iface_new_type"})) | ||
require.NoError(t, parser.Load(ctx)) | ||
|
||
for _, ifaceName := range []string{"Interface1", "Interface2", "Interface3"} { | ||
iface, err := parser.Find(ifaceName) | ||
require.NoError(t, err) | ||
require.NotNil(t, iface) | ||
} | ||
} | ||
|
||
func TestUsage(t *testing.T) { | ||
interface1 := NewMockInterface1(t) | ||
interface1.EXPECT().Method1().Return() | ||
interface1.Method1() | ||
|
||
interface2 := NewMockInterface2(t) | ||
interface2.EXPECT().Method1().Return() | ||
interface2.Method1() | ||
|
||
interface3 := NewMockInterface3(t) | ||
interface3.EXPECT().Method1().Return() | ||
interface3.Method1() | ||
} |
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,12 @@ | ||
package iface_new_type | ||
|
||
import "github.com/vektra/mockery/v2/pkg/fixtures/iface_new_type/subpkg" | ||
|
||
type Interface1 interface { | ||
Method1() | ||
} | ||
|
||
type ( | ||
Interface2 Interface1 | ||
Interface3 subpkg.SubPkgInterface | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
package subpkg | ||
|
||
type SubPkgInterface interface { | ||
Method1() | ||
} |
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