Skip to content

Commit

Permalink
wip: stub the osx commands during test
Browse files Browse the repository at this point in the history
  • Loading branch information
mefellows committed Feb 27, 2021
1 parent ecccfe4 commit c028109
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion v3/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (i *Installer) getLibDstForPackage(pkg string) (string, error) {
return path.Join(i.getLibDir(), pkgInfo.libName) + "." + osToExtension[i.os], nil
}

func setOSXInstallName(file string, lib string) error {
var setOSXInstallName = func(file string, lib string) error {
cmd := exec.Command("install_name_tool", "-id", fmt.Sprintf("../../libs/%s.dylib", lib), file)
stdoutStderr, err := cmd.CombinedOutput()

Expand Down
13 changes: 13 additions & 0 deletions v3/installer/installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ func TestInstallerCheckInstallation(t *testing.T) {

func TestInstallerCheckPackageInstall(t *testing.T) {
t.Run("downloads and install dependencies when existing libraries aren't present", func(t *testing.T) {
defer restoreOSXInstallName()()
mockFs := afero.NewMemMapFs()

var i *Installer

i = &Installer{
Expand Down Expand Up @@ -180,3 +182,14 @@ func (m *mockDownloader) download(src, dst string) error {

return nil
}

func restoreOSXInstallName() func() {
old := setOSXInstallName
setOSXInstallName = func(string, string) error {
return nil
}

return func() {
setOSXInstallName = old
}
}

0 comments on commit c028109

Please sign in to comment.