mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn test main commands (#481)
This commit is contained in:
@@ -30,7 +30,7 @@ func aliasesFn() []cli.Command {
|
||||
return cmds
|
||||
}
|
||||
|
||||
func main() {
|
||||
func newFn() *cli.App {
|
||||
app := cli.NewApp()
|
||||
app.Name = "fn"
|
||||
app.Version = fnversion
|
||||
@@ -77,6 +77,11 @@ GLOBAL OPTIONS:
|
||||
version(),
|
||||
}
|
||||
app.Commands = append(app.Commands, aliasesFn()...)
|
||||
return app
|
||||
}
|
||||
|
||||
func main() {
|
||||
app := newFn()
|
||||
app.Run(os.Args)
|
||||
}
|
||||
|
||||
|
||||
39
fn/main_test.go
Normal file
39
fn/main_test.go
Normal file
@@ -0,0 +1,39 @@
|
||||
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")
|
||||
|
||||
exec.Command("go", "build", "-o", fnTestBin).Run()
|
||||
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user