github.com/april1989/origin-go-tools@v0.0.32/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  // +build !plan9
     6  
     7  package main
     8  
     9  import (
    10  	"io/ioutil"
    11  	"os"
    12  	"path/filepath"
    13  	"testing"
    14  )
    15  
    16  func TestDownloadGoVersion(t *testing.T) {
    17  	if testing.Short() {
    18  		t.Skipf("Skipping download in short mode")
    19  	}
    20  
    21  	tmpd, err := ioutil.TempDir("", "go")
    22  	if err != nil {
    23  		t.Fatal(err)
    24  	}
    25  	defer os.RemoveAll(tmpd)
    26  
    27  	if err := downloadGoVersion("go1.8.1", "linux", "amd64", filepath.Join(tmpd, "go")); err != nil {
    28  		t.Fatal(err)
    29  	}
    30  
    31  	// Ensure the VERSION file exists.
    32  	vf := filepath.Join(tmpd, "go", "VERSION")
    33  	if _, err := os.Stat(vf); os.IsNotExist(err) {
    34  		t.Fatalf("file %s does not exist and should", vf)
    35  	}
    36  }