Skip to content

Commit 029a9f9

Browse files
committed
Fix(empty-return): move tests to correct location
1 parent fe8affb commit 029a9f9

File tree

6 files changed

+147
-133
lines changed

6 files changed

+147
-133
lines changed

.mockery.yaml

+11-3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ packages:
7070
mockname: "Mock{{.InterfaceName}}"
7171
outpkg: "{{.PackageName}}"
7272
inpackage: True
73+
github.com/vektra/mockery/v2/pkg/fixtures/empty_return:
74+
config:
75+
all: True
76+
dir: "{{.InterfaceDir}}"
77+
mockname: "{{.InterfaceName}}Mock"
78+
outpkg: "{{.PackageName}}"
79+
filename: "mock_{{.InterfaceName}}_test.go"
80+
inpackage: True
81+
keeptree: False
7382
github.com/vektra/mockery/v2/pkg/fixtures/method_args/same_name_arg_and_type:
7483
config:
7584
all: True
@@ -81,10 +90,10 @@ packages:
8190
keeptree: False
8291
github.com/vektra/mockery/v2/pkg/fixtures/iface_typed_param:
8392
config: *inpackage_config
84-
github.com/vektra/mockery/v2/pkg/fixtures/example_project:
93+
github.com/vektra/mockery/v2/pkg/fixtures/example_project:
8594
config: *inpackage_config
8695
github.com/vektra/mockery/v2/pkg/fixtures/issue845:
87-
config:
96+
config:
8897
<<: *inpackage_config
8998
filename: "mock_{{.MockName}}_test.go"
9099
interfaces:
@@ -108,4 +117,3 @@ packages:
108117
mockname: InterfaceWithUnresolvedAlias
109118
- resolve-type-alias: True
110119
mockname: InterfaceWithResolvedAlias
111-

mocks/github.com/vektra/mockery/v2/pkg/fixtures/EmptyReturn.go

-98
This file was deleted.

pkg/compat_test.go

-32
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/stretchr/testify/mock"
77
"github.com/stretchr/testify/suite"
88
mocks "github.com/vektra/mockery/v2/mocks/github.com/vektra/mockery/v2/pkg/fixtures"
9-
test "github.com/vektra/mockery/v2/pkg/fixtures"
109
)
1110

1211
// CompatSuite covers compatibility with github.com/stretchr/testify/mock.
@@ -36,37 +35,6 @@ func (s *CompatSuite) TestOnAnythingOfTypeVariadicArgs() {
3635
m.AssertCalled(t, "Sprintf", "int: %d string: %s", 22, "twenty two")
3736
}
3837

39-
func (s *CompatSuite) TestOnEmptyReturn() {
40-
m := mocks.NewEmptyReturn(s.T())
41-
var target test.EmptyReturn = m
42-
43-
s.Run("NoArgs", func() {
44-
run := false
45-
46-
m.EXPECT().NoArgs().RunAndReturn(func() {
47-
run = true
48-
})
49-
50-
target.NoArgs()
51-
52-
s.True(run)
53-
})
54-
55-
s.Run("WithArgs", func() {
56-
run := false
57-
58-
m.EXPECT().WithArgs(42, "foo").RunAndReturn(func(arg0 int, arg1 string) {
59-
run = true
60-
s.Equal(42, arg0)
61-
s.Equal("foo", arg1)
62-
})
63-
64-
target.WithArgs(42, "foo")
65-
66-
s.True(run)
67-
})
68-
}
69-
7038
func TestCompatSuite(t *testing.T) {
7139
mockcompatSuite := new(CompatSuite)
7240
suite.Run(t, mockcompatSuite)
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
func Test(t *testing.T) {
10+
m := NewEmptyReturnMock(t)
11+
var target EmptyReturn = m
12+
13+
t.Run("NoArgs", func(t *testing.T) {
14+
run := false
15+
16+
m.EXPECT().NoArgs().RunAndReturn(func() {
17+
run = true
18+
})
19+
20+
target.NoArgs()
21+
22+
require.True(t, run)
23+
})
24+
25+
t.Run("WithArgs", func(t *testing.T) {
26+
run := false
27+
28+
m.EXPECT().WithArgs(42, "foo").RunAndReturn(func(arg0 int, arg1 string) {
29+
run = true
30+
require.Equal(t, 42, arg0)
31+
require.Equal(t, "foo", arg1)
32+
})
33+
34+
target.WithArgs(42, "foo")
35+
36+
require.True(t, run)
37+
})
38+
}

pkg/fixtures/empty_return/mock_EmptyReturn_test.go

+98
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)