From 03a43e4905ae36abd839cefca0ab4461aa9d9943 Mon Sep 17 00:00:00 2001 From: Rohit Nayak Date: Fri, 10 Jan 2025 10:23:57 +0100 Subject: [PATCH] Remove unused function and related test Signed-off-by: Rohit Nayak --- go/cmd/internal/docgen/docgen.go | 8 ------ go/cmd/internal/docgen/docgen_test.go | 35 --------------------------- 2 files changed, 43 deletions(-) diff --git a/go/cmd/internal/docgen/docgen.go b/go/cmd/internal/docgen/docgen.go index b2777ff221a..26cb3d4df9b 100644 --- a/go/cmd/internal/docgen/docgen.go +++ b/go/cmd/internal/docgen/docgen.go @@ -146,20 +146,12 @@ func restructure(rootDir string, dir string, name string, commands []*cobra.Comm return fmt.Errorf("failed to move child command %s to its parent's dir: %w", fullCmdFilename, err) } - sed := newParentLinkSedCommand(name, newName) - if out, err := sed.CombinedOutput(); err != nil { - return fmt.Errorf("failed to rewrite links to parent command in child %s: %w (extra: %s)", newName, err, out) - } } } return nil } -func newParentLinkSedCommand(parent string, file string) *exec.Cmd { - return exec.Command("xyz", "-i", "-e", fmt.Sprintf("s:(./%s/):(../):i", parent), file) -} - var ( wd string once sync.Once diff --git a/go/cmd/internal/docgen/docgen_test.go b/go/cmd/internal/docgen/docgen_test.go index 741f5ecc577..207830f77ae 100644 --- a/go/cmd/internal/docgen/docgen_test.go +++ b/go/cmd/internal/docgen/docgen_test.go @@ -17,7 +17,6 @@ limitations under the License. package docgen import ( - "strings" "testing" "github.com/spf13/cobra" @@ -149,40 +148,6 @@ func TestLinkHandler(t *testing.T) { } } -func TestNewParentLinkSedCommand(t *testing.T) { - tests := []struct { - name string - parentDir string - fileName string - expectedOutput string - }{ - { - name: "Empty values", - expectedOutput: "sed -i -e s:(.//):(../):i ", - }, - { - name: "Normal value", - parentDir: "./", - fileName: "Some_value", - expectedOutput: "sed -i -e s:(././/):(../):i Some_value", - }, - { - name: "Abnormal value", - parentDir: "/root", - fileName: `./.jash13_24`, - expectedOutput: "sed -i -e s:(.//root/):(../):i ./.jash13_24", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - cmd := newParentLinkSedCommand(tt.parentDir, tt.fileName) - // We only check for suffix because the sed command's actual path may differ on different machines. - require.True(t, strings.HasSuffix(cmd.String(), tt.expectedOutput)) - }) - } -} - func TestGetCommitID(t *testing.T) { // This function should return an error when the reference is not in the // git tree.