refactor: implement mocking functions and tests
This commit is contained in:
parent
339dba4e13
commit
f8ef2ef2d5
21 changed files with 398 additions and 90 deletions
12
golang.go
12
golang.go
|
|
@ -1,9 +1,5 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type GolangManager struct{}
|
||||
|
||||
func (g *GolangManager) Install(packages []string) error {
|
||||
|
|
@ -22,19 +18,19 @@ func (g *GolangManager) Name() string {
|
|||
}
|
||||
|
||||
func (g *GolangManager) InstallManager() error {
|
||||
if _, err := exec.LookPath("brew"); err != nil {
|
||||
if _, err := execLookPath("brew"); err != nil {
|
||||
installHomebrew()
|
||||
}
|
||||
|
||||
if _, err := exec.LookPath("go"); err == nil {
|
||||
if _, err := execLookPath("go"); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := exec.Command("brew", "install", "golang")
|
||||
cmd := execCommand("brew", "install", "golang")
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (g *GolangManager) InstallPackage(pkg string) error {
|
||||
cmd := exec.Command("go", "install", pkg+"@latest")
|
||||
cmd := execCommand("go", "install", pkg+"@latest")
|
||||
return cmd.Run()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue