Skip to content

Commit c8d5b86

Browse files
committed
make GOOS and GOARCH global vars to allow testing
1 parent 5677941 commit c8d5b86

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tools/download.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ var systems = map[string]string{
7373
"linuxarm": "arm-linux-gnueabihf",
7474
}
7575

76+
// public vars to allow override in the tests
77+
var (
78+
OS = runtime.GOOS
79+
Arch = runtime.GOARCH
80+
)
81+
7682
func mimeType(data []byte) (string, error) {
7783
return http.DetectContentType(data[0:512]), nil
7884
}
@@ -321,7 +327,7 @@ func findTool(pack, name, version string, data index) (tool, system) {
321327
maxSimilarity := 0.7
322328

323329
for _, s := range correctTool.Systems {
324-
similarity := smetrics.Jaro(s.Host, systems[runtime.GOOS+runtime.GOARCH])
330+
similarity := smetrics.Jaro(s.Host, systems[OS+Arch])
325331
if similarity > maxSimilarity {
326332
correctSystem = s
327333
maxSimilarity = similarity
@@ -587,7 +593,7 @@ func (t *Tools) installDrivers(location string) error {
587593
OkPressed := 6
588594
extension := ".bat"
589595
preamble := ""
590-
if runtime.GOOS != "windows" {
596+
if OS != "windows" {
591597
extension = ".sh"
592598
// add ./ to force locality
593599
preamble = "./"
@@ -599,7 +605,7 @@ func (t *Tools) installDrivers(location string) error {
599605
os.Chdir(location)
600606
t.Logger(preamble + "post_install" + extension)
601607
oscmd := exec.Command(preamble + "post_install" + extension)
602-
if runtime.GOOS != "linux" {
608+
if OS != "linux" {
603609
// spawning a shell could be the only way to let the user type his password
604610
TellCommandNotToSpawnShell(oscmd)
605611
}

0 commit comments

Comments
 (0)