From 3cd5b15466fe4065ef76ea5c557dab435a7d7318 Mon Sep 17 00:00:00 2001 From: Dmitrii Anoshin Date: Wed, 28 Feb 2024 23:12:12 -0800 Subject: [PATCH] [chore] [mdatagen] Use directory name as package name for generated files (#31500) Use the directory name for the package in generated files. Composing the name doesn't match the reality for extensions. --- cmd/mdatagen/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/mdatagen/main.go b/cmd/mdatagen/main.go index 2aa239b5ad8c..eaa05ce77c11 100644 --- a/cmd/mdatagen/main.go +++ b/cmd/mdatagen/main.go @@ -43,6 +43,7 @@ func run(ymlPath string) error { } ymlDir := filepath.Dir(ymlPath) + packageName := filepath.Base(ymlDir) md, err := loadMetadata(ymlPath) if err != nil { @@ -75,7 +76,7 @@ func run(ymlPath string) error { if md.Tests != nil { if err = generateFile(filepath.Join(tmplDir, "component_test.go.tmpl"), - filepath.Join(ymlDir, "generated_component_test.go"), md, md.ShortFolderName+md.Status.Class); err != nil { + filepath.Join(ymlDir, "generated_component_test.go"), md, packageName); err != nil { return err } }