github.com/Xenoex/gopm@v0.6.5/cmd/get_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/Unknwon/com"
     5  	"os"
     6  	"os/exec"
     7  	"testing"
     8  )
     9  
    10  func TestConflicts(t *testing.T) {
    11  	var err error
    12  	_, err = exec.Command("gopm", "get", "-l", "-r").Output()
    13  	_, err = exec.Command("gopm", "get", "-g", "-r").Output()
    14  	_, err = exec.Command("gopm", "get", "-g", "-l").Output()
    15  	if err == nil {
    16  		t.Fatal("cannot ignore conflicts flags")
    17  	}
    18  }
    19  func TestGetAndRun(t *testing.T) {
    20  	os.Chdir("testproject")
    21  	defer func() {
    22  		os.RemoveAll("src/github.com")
    23  		os.Remove("bin")
    24  		os.Remove("pkg")
    25  		os.Remove(".gopmfile")
    26  		os.Chdir("..")
    27  	}()
    28  	_, err := exec.Command("gopm", "gen", "-l").Output()
    29  	if err != nil {
    30  		t.Log(err)
    31  	}
    32  	if !com.IsDir("bin") || !com.IsDir("pkg") {
    33  		t.Fatal("Gen bin and pkg directories failed.")
    34  	}
    35  	_, err = exec.Command("gopm", "get", "-l").Output()
    36  	if !com.IsDir("src/github.com") {
    37  		t.Fatal("Get packages failed")
    38  	}
    39  	out, err := exec.Command("gopm", "run", "-l").Output()
    40  	if err != nil || string(out) != "TEST\n" {
    41  		t.Fatal("Run failed \t", err.Error())
    42  	}
    43  }