Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonTClipp committed Jan 20, 2025
1 parent 61aa867 commit 52a82ea
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions internal/fixtures/example_project/replace_type/rt_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package replace_type

import (
"strings"
"testing"

"github.com/chigopher/pathlib"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestReplaceType(t *testing.T) {
mockFile := pathlib.NewPath("./mocks_replace_type_test.go")
b, err := mockFile.ReadFile()
require.NoError(t, err)
// .mockery.yml replaced github.com/vektra/mockery/v3/internal/fixtures/example_project/replace_type/rti/rt1
// with github.com/vektra/mockery/v3/internal/fixtures/example_project/replace_type/rti/rt2
assert.True(t, strings.Contains(string(b), "*RTypeReplaced1) Replace1(f rt2.RType2) {"))
// This should contain no replaced type.
assert.True(t, strings.Contains(string(b), "*MockRType) Replace1(f rt1.RType1) {"))
}
4 changes: 2 additions & 2 deletions internal/fixtures/expecter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (

// Test that the generated code for ExpecterTest interface is usable
func TestExpecter(t *testing.T) {
expMock := NewMockExpecter(t)
expMock := MockExpecter{}

t.Run("NoArg", func(t *testing.T) {
var runCalled bool
Expand All @@ -34,7 +34,7 @@ func TestExpecter(t *testing.T) {
// Call again panic
assert.Panics(t, func() {
expMock.NoArg()
}, "call did not panic")
})
expMock.AssertExpectations(t)
})

Expand Down
2 changes: 1 addition & 1 deletion internal/fixtures/type_alias/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestTypeAlias(t *testing.T) {
}{
{
name: "With alias unresolved",
filepath: "./mocks_test.go",
filepath: "./mocks_type_alias_test.go",
expectedRegex: `func \(_mock \*MockInterface1\) Foo\(\) Type {`,
},
} {
Expand Down

0 comments on commit 52a82ea

Please sign in to comment.