Skip to content

Commit 63071ff

Browse files
committed
Add unit tests for cli alpha generate.go
lint fix Modify Tests Minor-1 Minor fix Minor fix 1 Minor fix 2 Minor fix 3 Minor fix 4 Fix - 4 Comments - 1
1 parent 3fd0419 commit 63071ff

File tree

2 files changed

+755
-2
lines changed

2 files changed

+755
-2
lines changed

pkg/cli/alpha/internal/generate.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ type Generate struct {
4242
OutputDir string
4343
}
4444

45+
// Define a variable to allow overriding the behavior of getExecutablePath for testing.
46+
var getExecutablePathFunc = getExecutablePath
47+
4548
// Generate handles the migration and scaffolding process.
4649
func (opts *Generate) Generate() error {
4750
projectConfig, err := common.LoadProjectConfig(opts.InputDir)
@@ -144,7 +147,7 @@ func (opts *Generate) Validate() error {
144147
return fmt.Errorf("error getting input path %q: %w", opts.InputDir, err)
145148
}
146149

147-
_, err = getExecutablePath()
150+
_, err = getExecutablePathFunc()
148151
if err != nil {
149152
return err
150153
}
@@ -188,7 +191,7 @@ func changeWorkingDirectory(outputDir string) error {
188191
// Initializes the project with Kubebuilder.
189192
func kubebuilderInit(s store.Store) error {
190193
args := append([]string{"init"}, getInitArgs(s)...)
191-
execPath, err := getExecutablePath()
194+
execPath, err := getExecutablePathFunc()
192195
if err != nil {
193196
return err
194197
}

0 commit comments

Comments
 (0)