Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
RangelReale committed Mar 10, 2023
1 parent 6e9b6a1 commit fefb94b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type GeneratorConfig struct {
StructName string
UnrollVariadic bool
WithExpecter bool
ReplaceType []string
}

// Generator is responsible for generating the string containing
Expand Down Expand Up @@ -206,7 +207,7 @@ func (g *Generator) addPackageImportWithName(ctx context.Context, path, name str
}

func (g *Generator) parseReplaceTypes(ctx context.Context) {
for _, replace := range g.Config.ReplaceType {
for _, replace := range g.config.ReplaceType {
r := strings.SplitN(replace, "=", 2)
if len(r) != 2 {
log := zerolog.Ctx(ctx)
Expand Down
4 changes: 2 additions & 2 deletions pkg/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2433,7 +2433,7 @@ import mock "github.com/stretchr/testify/mock"
`
generator := NewGenerator(
s.ctx,
config.Config{InPackage: false, LogLevel: "debug", ReplaceType: []string{
GeneratorConfig{InPackage: false, ReplaceType: []string{
"github.com/vektra/mockery/v2/pkg/fixtures/example_project/baz/internal/foo.InternalBaz=baz:github.com/vektra/mockery/v2/pkg/fixtures/example_project/baz.Baz",
}},
s.getInterfaceFromFile("example_project/baz/foo.go", "Foo"),
Expand Down Expand Up @@ -2504,7 +2504,7 @@ func NewFoo(t mockConstructorTestingTNewFoo) *Foo {
return mock
}
`
cfg := config.Config{InPackage: false, LogLevel: "debug", ReplaceType: []string{
cfg := GeneratorConfig{InPackage: false, ReplaceType: []string{
"github.com/vektra/mockery/v2/pkg/fixtures/example_project/baz/internal/foo.InternalBaz=baz:github.com/vektra/mockery/v2/pkg/fixtures/example_project/baz.Baz",
}}

Expand Down
1 change: 1 addition & 0 deletions pkg/outputter.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func (m *Outputter) Generate(ctx context.Context, iface *Interface) error {
StructName: interfaceConfig.StructName,
UnrollVariadic: interfaceConfig.UnrollVariadic,
WithExpecter: interfaceConfig.WithExpecter,
ReplaceType: interfaceConfig.ReplaceType,
}
generator := NewGenerator(ctx, g, iface, "")

Expand Down
2 changes: 2 additions & 0 deletions pkg/walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type GeneratorVisitorConfig struct {
StructName string
UnrollVariadic bool
WithExpecter bool
ReplaceType []string
}

type GeneratorVisitor struct {
Expand Down Expand Up @@ -173,6 +174,7 @@ func (v *GeneratorVisitor) VisitWalk(ctx context.Context, iface *Interface) erro
StructName: v.config.StructName,
UnrollVariadic: v.config.UnrollVariadic,
WithExpecter: v.config.WithExpecter,
ReplaceType: v.config.ReplaceType,
}

gen := NewGenerator(ctx, generatorConfig, iface, "")
Expand Down

0 comments on commit fefb94b

Please sign in to comment.