Add time.Duration flag type

This commit is contained in:
Ghislain Gt
2014-08-02 22:32:32 +01:00
parent c7ff3bf705
commit 98af61a59f
4 changed files with 99 additions and 3 deletions

View File

@@ -2,8 +2,10 @@ package cli_test
import (
"flag"
"github.com/codegangsta/cli"
"testing"
"time"
"github.com/codegangsta/cli"
)
func TestNewContext(t *testing.T) {
@@ -26,6 +28,13 @@ func TestContext_Int(t *testing.T) {
expect(t, c.Int("myflag"), 12)
}
func TestContext_Duration(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.Duration("myflag", time.Duration(12*time.Second), "doc")
c := cli.NewContext(nil, set, set)
expect(t, c.Duration("myflag"), time.Duration(12*time.Second))
}
func TestContext_String(t *testing.T) {
set := flag.NewFlagSet("test", 0)
set.String("myflag", "hello world", "doc")