mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-15 19:22:46 -06:00
7ccd6204c4
For unit testing in particular we can't launch a real browser for testing, so this indirection is primarily to allow us to substitute a mock when testing a command that can launch a browser. This includes a simple mock implementation that expects to interact with a running web server directly.
19 lines
425 B
Go
19 lines
425 B
Go
package webbrowser
|
|
|
|
import (
|
|
"github.com/pkg/browser"
|
|
)
|
|
|
|
// NewNativeLauncher creates and returns a Launcher that will attempt to interact
|
|
// with the browser-launching mechanisms of the operating system where the
|
|
// program is currently running.
|
|
func NewNativeLauncher() Launcher {
|
|
return nativeLauncher{}
|
|
}
|
|
|
|
type nativeLauncher struct{}
|
|
|
|
func (l nativeLauncher) OpenURL(url string) error {
|
|
return browser.OpenURL(url)
|
|
}
|