From 527c0c4bfc7821d7cdaf704bd4b91b70c77b7ac1 Mon Sep 17 00:00:00 2001 From: Ishai Strauss Date: Wed, 17 Apr 2024 15:53:59 +0300 Subject: [PATCH 1/3] Added InterfaceFile --- pkg/outputter.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/outputter.go b/pkg/outputter.go index 1960be9b..d35653bc 100644 --- a/pkg/outputter.go +++ b/pkg/outputter.go @@ -210,6 +210,7 @@ func parseConfigTemplates(ctx context.Context, c *config.Config, iface *Interfac data := struct { InterfaceDir string InterfaceDirRelative string + InterfaceFile string InterfaceName string InterfaceNameCamel string InterfaceNameLowerCamel string @@ -222,6 +223,7 @@ func parseConfigTemplates(ctx context.Context, c *config.Config, iface *Interfac }{ InterfaceDir: filepath.Dir(iface.FileName), InterfaceDirRelative: interfaceDirRelative, + InterfaceFile: iface.FileName, InterfaceName: iface.Name, // Deprecated: All custom case variables of InterfaceName will be removed in the next major version // Use the template functions instead From dff9d5479f6c89959bc55faf159c7741b031dbaf Mon Sep 17 00:00:00 2001 From: Ishai Date: Tue, 23 Apr 2024 22:06:08 +0300 Subject: [PATCH 2/3] added .InterfaceFile test --- pkg/outputter_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/outputter_test.go b/pkg/outputter_test.go index 8c7b860c..9701d176 100644 --- a/pkg/outputter_test.go +++ b/pkg/outputter_test.go @@ -97,7 +97,7 @@ func Test_parseConfigTemplates(t *testing.T) { args: args{ c: &config.Config{ Dir: "{{.InterfaceDir}}/{{.PackagePath}}", - FileName: "{{.InterfaceName}}_{{.InterfaceNameCamel}}_{{.InterfaceNameSnake}}_{{.InterfaceNameLower}}.go", + FileName: "{{.InterfaceName}}_{{.InterfaceNameCamel}}_{{.InterfaceNameSnake}}_{{.InterfaceNameLower}}_{{.InterfaceFile}}", MockName: "{{.InterfaceNameLowerCamel}}", Outpkg: "{{.PackageName}}", }, @@ -110,7 +110,7 @@ func Test_parseConfigTemplates(t *testing.T) { pkg: mockPkg, want: &config.Config{ Dir: "path/to/github.com/user/project/package", - FileName: "FooBar_FooBar_foo_bar_foobar.go", + FileName: "FooBar_FooBar_foo_bar_foobar_foobar.go", MockName: "fooBar", Outpkg: "packageName", }, From 314f11ac0a79b722250fe000bb295c4caee2c924 Mon Sep 17 00:00:00 2001 From: Ishai Date: Tue, 23 Apr 2024 23:00:17 +0300 Subject: [PATCH 3/3] fixed .InterfaceFile test --- pkg/outputter_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/outputter_test.go b/pkg/outputter_test.go index 9701d176..5e21d821 100644 --- a/pkg/outputter_test.go +++ b/pkg/outputter_test.go @@ -97,7 +97,7 @@ func Test_parseConfigTemplates(t *testing.T) { args: args{ c: &config.Config{ Dir: "{{.InterfaceDir}}/{{.PackagePath}}", - FileName: "{{.InterfaceName}}_{{.InterfaceNameCamel}}_{{.InterfaceNameSnake}}_{{.InterfaceNameLower}}_{{.InterfaceFile}}", + FileName: "{{.InterfaceName}}_{{.InterfaceNameCamel}}_{{.InterfaceNameSnake}}_{{.InterfaceNameLower}}_{{base .InterfaceFile}}", MockName: "{{.InterfaceNameLowerCamel}}", Outpkg: "{{.PackageName}}", },