refactor(packagemanager,cli,tui): move packages in specific subfolders
This commit is contained in:
parent
11b8541630
commit
e49138fdd2
34 changed files with 18 additions and 18 deletions
45
pkg/packagemanager/pipx_test.go
Normal file
45
pkg/packagemanager/pipx_test.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package packagemanager
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"system_setup_tool/internal/shell"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPipxManager_Name(t *testing.T) {
|
||||
pm := &PipxManager{}
|
||||
if name := pm.Name(); name != "Pipx" {
|
||||
t.Errorf("Expected name to be 'Pipx', got %s", name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPipxManager_InstallManager(t *testing.T) {
|
||||
pm := &PipxManager{}
|
||||
|
||||
// Mock exec.LookPath
|
||||
shell.ExecLookPath = func(file string) (string, error) {
|
||||
if file == "pipx" {
|
||||
return "/usr/bin/pipx", nil
|
||||
}
|
||||
return "", exec.ErrNotFound
|
||||
}
|
||||
defer func() { shell.ExecLookPath = exec.LookPath }()
|
||||
|
||||
if err := pm.InstallManager(); err != nil {
|
||||
t.Errorf("Expected no error, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPipxManager_InstallPackage(t *testing.T) {
|
||||
pm := &PipxManager{}
|
||||
|
||||
// Mock exec.Command
|
||||
shell.ExecCommand = func(name string, arg ...string) *exec.Cmd {
|
||||
return exec.Command("echo", "mocked pipx install")
|
||||
}
|
||||
defer func() { shell.ExecCommand = exec.Command }()
|
||||
|
||||
if err := pm.InstallPackage("test-package"); err != nil {
|
||||
t.Errorf("Expected no error, got %v", err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue