More test tweaking

This commit is contained in:
Jeremy Saenz 2013-07-20 15:53:25 -07:00
parent ed1ee94250
commit e14e45d087
2 changed files with 13 additions and 12 deletions

View File

@ -1,45 +1,46 @@
package cli package cli_test
import ( import (
"flag" "flag"
"testing" "testing"
"github.com/codegangsta/cli"
) )
func Test_New(t *testing.T) { func TestNewContext(t *testing.T) {
set := flag.NewFlagSet("test", 0) set := flag.NewFlagSet("test", 0)
set.Int("myflag", 12, "doc") set.Int("myflag", 12, "doc")
globalSet := flag.NewFlagSet("test", 0) globalSet := flag.NewFlagSet("test", 0)
globalSet.Int("myflag", 42, "doc") globalSet.Int("myflag", 42, "doc")
c := NewContext(nil, set, globalSet) c := cli.NewContext(nil, set, globalSet)
expect(t, c.Int("myflag"), 12) expect(t, c.Int("myflag"), 12)
expect(t, c.GlobalInt("myflag"), 42) expect(t, c.GlobalInt("myflag"), 42)
} }
func Test_Int(t *testing.T) { func TestContext_Int(t *testing.T) {
set := flag.NewFlagSet("test", 0) set := flag.NewFlagSet("test", 0)
set.Int("myflag", 12, "doc") set.Int("myflag", 12, "doc")
c := NewContext(nil, set, set) c := cli.NewContext(nil, set, set)
expect(t, c.Int("myflag"), 12) expect(t, c.Int("myflag"), 12)
} }
func Test_String(t *testing.T) { func TestContext_String(t *testing.T) {
set := flag.NewFlagSet("test", 0) set := flag.NewFlagSet("test", 0)
set.String("myflag", "hello world", "doc") set.String("myflag", "hello world", "doc")
c := NewContext(nil, set, set) c := cli.NewContext(nil, set, set)
expect(t, c.String("myflag"), "hello world") expect(t, c.String("myflag"), "hello world")
} }
func Test_Bool(t *testing.T) { func TestContext_Bool(t *testing.T) {
set := flag.NewFlagSet("test", 0) set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc") set.Bool("myflag", false, "doc")
c := NewContext(nil, set, set) c := cli.NewContext(nil, set, set)
expect(t, c.Bool("myflag"), false) expect(t, c.Bool("myflag"), false)
} }
func Test_Args(t *testing.T) { func TestContext_Args(t *testing.T) {
set := flag.NewFlagSet("test", 0) set := flag.NewFlagSet("test", 0)
set.Bool("myflag", false, "doc") set.Bool("myflag", false, "doc")
c := NewContext(nil, set, set) c := cli.NewContext(nil, set, set)
set.Parse([]string{"--myflag", "bat", "baz"}) set.Parse([]string{"--myflag", "bat", "baz"})
expect(t, len(c.Args()), 2) expect(t, len(c.Args()), 2)
expect(t, c.Bool("myflag"), true) expect(t, c.Bool("myflag"), true)

View File

@ -1,4 +1,4 @@
package cli package cli_test
import ( import (
"reflect" "reflect"