Adding VersionPrinter and tests.

This commit is contained in:
Joshua Mervine
2014-06-17 21:37:55 -07:00
committed by Josh Mervine
parent bb9189510a
commit 5821632000
2 changed files with 28 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ package cli_test
import (
"fmt"
"github.com/codegangsta/cli"
"."
"os"
"testing"
)
@@ -347,6 +347,26 @@ func TestAppHelpPrinter(t *testing.T) {
}
}
func TestAppVersionPrinter(t *testing.T) {
oldPrinter := cli.VersionPrinter
defer func() {
cli.VersionPrinter = oldPrinter
}()
var wasCalled = false
cli.VersionPrinter = func(c *cli.Context) {
wasCalled = true
}
app := cli.NewApp()
ctx := cli.NewContext(app, nil, nil)
cli.ShowVersion(ctx)
if wasCalled == false {
t.Errorf("Version printer expected to be called, but was not")
}
}
func TestAppCommandNotFound(t *testing.T) {
beforeRun, subcommandRun := false, false
app := cli.NewApp()