Skip to content

Commit

Permalink
Remove unused function and related test
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
  • Loading branch information
rohit-nayak-ps committed Jan 10, 2025
1 parent fc414bc commit 03a43e4
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
8 changes: 0 additions & 8 deletions go/cmd/internal/docgen/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 0 additions & 35 deletions go/cmd/internal/docgen/docgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package docgen

import (
"strings"
"testing"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 03a43e4

Please sign in to comment.