Skip to content

Commit

Permalink
conflicts resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
zcolleen committed Apr 12, 2023
2 parents eaeaf6d + 818d20a commit db99344
Show file tree
Hide file tree
Showing 7 changed files with 531 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cmd/minimock/minimock.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,22 @@ func processPackage(opts generator.Options, interfaces []types.InterfaceSpecific
for _, iface := range interfaces {
opts.InterfaceName = iface.InterfaceName

params := ""
params := []string{}
paramsReferences := ""

for _, param := range iface.InterfaceParams {
names := strings.Join(param.ParamNames, ",")
params += fmt.Sprintf("%s %s", names, param.ParamType)

params = append(params, fmt.Sprintf("%s %s", names, param.ParamType))
if paramsReferences == "" {
paramsReferences = names
} else {
paramsReferences = strings.Join([]string{paramsReferences, names}, ",")
}
}

paramsString := strings.Join(params, ",")

opts.OutputFile, err = destinationFile(iface.InterfaceName, writeTo, suffix)
if err != nil {
return errors.Wrapf(err, "failed to generate mock for %s", iface.InterfaceName)
Expand All @@ -160,8 +163,8 @@ func processPackage(opts generator.Options, interfaces []types.InterfaceSpecific
// Due to limitations of the generator, type params render is done by additional functions
// params generates tokens for type param declarations, i.e. for declaring a generic function
opts.Funcs["params"] = func() string {
if params != "" {
return "[" + params + "]"
if paramsString != "" {
return "[" + paramsString + "]"
}
return ""
}
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
2 changes: 2 additions & 0 deletions internal/types/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"bytes"
"fmt"
"go/ast"
"go/printer"
"go/token"
Expand Down Expand Up @@ -54,6 +55,7 @@ func FindAllInterfaces(p *ast.Package, pattern string) []InterfaceSpecification
})
}

fmt.Printf("interfaceSpecifications: %+v\n", interfaceSpecifications)
return interfaceSpecifications
}

Expand Down
5 changes: 5 additions & 0 deletions snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func TestSnapshot(t *testing.T) {
args: []string{"-o", "./tests/package_name_specified_test.go", "-i", "./tests.*", "-p", "tests_test"},
wantErr: true,
},
{
name: "2 generic arguments with different types",
args: []string{"-o", "./tests/generic_multiple_args_with_different_types.go", "-i", "./tests.genericMultipleTypes"},
expectedOutputFile: "./tests/generic_multiple_args_with_different_types.go",
},
}

for _, testCase := range testCases {
Expand Down
256 changes: 256 additions & 0 deletions snapshots/TestSnapshot-2_generic_arguments_with_different_types.go

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

Loading

0 comments on commit db99344

Please sign in to comment.