You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
package cmd
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// func TestVersion(t *testing.T) {
|
|
// // FIXME maybe PanicOnExit0 can help regarding unexpected call to os.Exit(0) during test
|
|
// appname := "unittest"
|
|
// version := "0.0.1"
|
|
// cmd := newVersionCmd(version, appname)
|
|
// b := bytes.NewBufferString("")
|
|
// cmd.SetOut(b)
|
|
// if err := cmd.Execute(); err != nil {
|
|
// t.Fatal(err)
|
|
// }
|
|
// out, err := ioutil.ReadAll(b)
|
|
// if err != nil {
|
|
// t.Fatal(err)
|
|
// }
|
|
// expected := appname + " version " + version
|
|
// got := strings.TrimSpace(string(out))
|
|
// if got != expected {
|
|
// t.Fatalf("expected \"%s\" got \"%s\"", expected, got)
|
|
// }
|
|
// }
|
|
|
|
func TestInitalize(t *testing.T) {
|
|
_, flagCfg, err := Initialize("0.0.1", "unittest", "")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(flagCfg) == 0 {
|
|
t.Fatal("flag configuration missing")
|
|
}
|
|
}
|
|
|
|
// func TestVersion(t *testing.T) {
|
|
// args := []string{"version"}
|
|
// rootCmd.SetArgs(args)
|
|
// if err := rootCmd.Execute(); err != nil {
|
|
// t.Errorf("%v\n", err)
|
|
// }
|
|
// if err := Initialize("0.0.1", "unittest", ""); err != nil {
|
|
// t.Errorf("%v\n", err)
|
|
// }
|
|
// }
|