github.com/iron-io/functions@v0.0.0-20180820112432-d59d7d1c40b2/fn/main_test.go (about)

     1  package main
     2  
     3  import (
     4  	"bytes"
     5  	"os"
     6  	"os/exec"
     7  	"path"
     8  	"strings"
     9  	"testing"
    10  )
    11  
    12  func TestMainCommands(t *testing.T) {
    13  	testCommands := []string{
    14  		"init",
    15  		"apps",
    16  		"routes",
    17  		"images",
    18  		"lambda",
    19  		"version",
    20  		"build",
    21  		"bump",
    22  		"deploy",
    23  		"run",
    24  		"push",
    25  	}
    26  
    27  	fnTestBin := path.Join(os.TempDir(), "fn-test")
    28  
    29  	exec.Command("go", "build", "-o", fnTestBin).Run()
    30  
    31  	for _, cmd := range testCommands {
    32  		res, err := exec.Command(fnTestBin, strings.Split(cmd, " ")...).CombinedOutput()
    33  		if bytes.Contains(res, []byte("command not found")) {
    34  			t.Error(err)
    35  		}
    36  	}
    37  
    38  	os.Remove(fnTestBin)
    39  }