Use SetPrepareCmd hook to spy on OpenInBrowser

We are now able to assert that the browse command was called with the correct URL
This commit is contained in:
Mislav Marohnić 2019-11-01 22:18:12 +01:00
parent d881a2e52e
commit f6fcdf114e
3 changed files with 46 additions and 31 deletions

View file

@ -27,7 +27,7 @@ func ConcatPaths(paths ...string) string {
return strings.Join(paths, "/")
}
var OpenInBrowser = func(url string) error {
func OpenInBrowser(url string) error {
browser := os.Getenv("BROWSER")
if browser == "" {
browser = searchBrowserLauncher(runtime.GOOS)
@ -45,7 +45,8 @@ var OpenInBrowser = func(url string) error {
}
endingArgs := append(browserArgs[1:], url)
return exec.Command(browserArgs[0], endingArgs...).Run()
browseCmd := exec.Command(browserArgs[0], endingArgs...)
return PrepareCmd(browseCmd).Run()
}
func searchBrowserLauncher(goos string) (browser string) {