github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/cmd/getgo/download_test.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !plan9
     6  // +build !plan9
     7  
     8  package main
     9  
    10  import (
    11  	"io/ioutil"
    12  	"os"
    13  	"path/filepath"
    14  	"testing"
    15  )
    16  
    17  func TestDownloadGoVersion(t *testing.T) {
    18  	if testing.Short() {
    19  		t.Skipf("Skipping download in short mode")
    20  	}
    21  
    22  	tmpd, err := ioutil.TempDir("", "go")
    23  	if err != nil {
    24  		t.Fatal(err)
    25  	}
    26  	defer os.RemoveAll(tmpd)
    27  
    28  	if err := downloadGoVersion("go1.8.1", "linux", "amd64", filepath.Join(tmpd, "go")); err != nil {
    29  		t.Fatal(err)
    30  	}
    31  
    32  	// Ensure the VERSION file exists.
    33  	vf := filepath.Join(tmpd, "go", "VERSION")
    34  	if _, err := os.Stat(vf); os.IsNotExist(err) {
    35  		t.Fatalf("file %s does not exist and should", vf)
    36  	}
    37  }