mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
43 lines
672 B
Go
43 lines
672 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"os/exec"
|
|
"path"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestMainCommands(t *testing.T) {
|
|
testCommands := []string{
|
|
"init",
|
|
"apps",
|
|
"routes",
|
|
"images",
|
|
"lambda",
|
|
"version",
|
|
"build",
|
|
"bump",
|
|
"deploy",
|
|
"run",
|
|
"push",
|
|
}
|
|
|
|
fnTestBin := path.Join(os.TempDir(), "fn-test")
|
|
|
|
err := exec.Command("go", "build", "-o", fnTestBin).Run()
|
|
if err != nil {
|
|
t.Fatalf("Failed to build fn: err: %s", err)
|
|
}
|
|
|
|
for _, cmd := range testCommands {
|
|
res, err := exec.Command(fnTestBin, strings.Split(cmd, " ")...).CombinedOutput()
|
|
if bytes.Contains(res, []byte("command not found")) {
|
|
t.Error(err)
|
|
}
|
|
}
|
|
|
|
os.Remove(fnTestBin)
|
|
}
|