Skip to content

Commit

Permalink
Fix(empty-return): move tests to correct location
Browse files Browse the repository at this point in the history
  • Loading branch information
sonalys committed Nov 23, 2024
1 parent fe8affb commit 029a9f9
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 133 deletions.
14 changes: 11 additions & 3 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ packages:
mockname: "Mock{{.InterfaceName}}"
outpkg: "{{.PackageName}}"
inpackage: True
github.com/vektra/mockery/v2/pkg/fixtures/empty_return:
config:
all: True
dir: "{{.InterfaceDir}}"
mockname: "{{.InterfaceName}}Mock"
outpkg: "{{.PackageName}}"
filename: "mock_{{.InterfaceName}}_test.go"
inpackage: True
keeptree: False
github.com/vektra/mockery/v2/pkg/fixtures/method_args/same_name_arg_and_type:
config:
all: True
Expand All @@ -81,10 +90,10 @@ packages:
keeptree: False
github.com/vektra/mockery/v2/pkg/fixtures/iface_typed_param:
config: *inpackage_config
github.com/vektra/mockery/v2/pkg/fixtures/example_project:
github.com/vektra/mockery/v2/pkg/fixtures/example_project:
config: *inpackage_config
github.com/vektra/mockery/v2/pkg/fixtures/issue845:
config:
config:
<<: *inpackage_config
filename: "mock_{{.MockName}}_test.go"
interfaces:
Expand All @@ -108,4 +117,3 @@ packages:
mockname: InterfaceWithUnresolvedAlias
- resolve-type-alias: True
mockname: InterfaceWithResolvedAlias

98 changes: 0 additions & 98 deletions mocks/github.com/vektra/mockery/v2/pkg/fixtures/EmptyReturn.go

This file was deleted.

32 changes: 0 additions & 32 deletions pkg/compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
mocks "github.com/vektra/mockery/v2/mocks/github.com/vektra/mockery/v2/pkg/fixtures"
test "github.com/vektra/mockery/v2/pkg/fixtures"
)

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

func (s *CompatSuite) TestOnEmptyReturn() {
m := mocks.NewEmptyReturn(s.T())
var target test.EmptyReturn = m

s.Run("NoArgs", func() {
run := false

m.EXPECT().NoArgs().RunAndReturn(func() {
run = true
})

target.NoArgs()

s.True(run)
})

s.Run("WithArgs", func() {
run := false

m.EXPECT().WithArgs(42, "foo").RunAndReturn(func(arg0 int, arg1 string) {
run = true
s.Equal(42, arg0)
s.Equal("foo", arg1)
})

target.WithArgs(42, "foo")

s.True(run)
})
}

func TestCompatSuite(t *testing.T) {
mockcompatSuite := new(CompatSuite)
suite.Run(t, mockcompatSuite)
Expand Down
File renamed without changes.
38 changes: 38 additions & 0 deletions pkg/fixtures/empty_return/interface_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package test

import (
"testing"

"github.com/stretchr/testify/require"
)

func Test(t *testing.T) {
m := NewEmptyReturnMock(t)
var target EmptyReturn = m

t.Run("NoArgs", func(t *testing.T) {
run := false

m.EXPECT().NoArgs().RunAndReturn(func() {
run = true
})

target.NoArgs()

require.True(t, run)
})

t.Run("WithArgs", func(t *testing.T) {
run := false

m.EXPECT().WithArgs(42, "foo").RunAndReturn(func(arg0 int, arg1 string) {
run = true
require.Equal(t, 42, arg0)
require.Equal(t, "foo", arg1)
})

target.WithArgs(42, "foo")

require.True(t, run)
})
}
98 changes: 98 additions & 0 deletions pkg/fixtures/empty_return/mock_EmptyReturn_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 029a9f9

Please sign in to comment.