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 b934296 commit 9be07da
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 132 deletions.
11 changes: 10 additions & 1 deletion .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,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 @@ -77,4 +86,4 @@ packages:
mockname: "{{.InterfaceName}}"
outpkg: "{{.PackageName}}_test"
filename: "{{.InterfaceNameSnake}}_mock_test.go"
keeptree: True
keeptree: True
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.

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

0 comments on commit 9be07da

Please sign in to comment.