move helper to file
This commit is contained in:
38
provider/arg/helper_test.go
Normal file
38
provider/arg/helper_test.go
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
package arg_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gitoa.ru/go-4devs/config"
|
||||||
|
"gitoa.ru/go-4devs/config/definition"
|
||||||
|
"gitoa.ru/go-4devs/config/definition/group"
|
||||||
|
"gitoa.ru/go-4devs/config/definition/option"
|
||||||
|
"gitoa.ru/go-4devs/config/definition/proto"
|
||||||
|
"gitoa.ru/go-4devs/config/provider/arg"
|
||||||
|
"gitoa.ru/go-4devs/config/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
func testOptions(t *testing.T) config.Options {
|
||||||
|
t.Helper()
|
||||||
|
|
||||||
|
def := definition.New()
|
||||||
|
def.Add(
|
||||||
|
option.Int("listen", "listen", option.Short('l'), option.Default(8080)),
|
||||||
|
option.String("config", "config", arg.Argument, option.Default("config.hcl")),
|
||||||
|
group.New("user", "configure user",
|
||||||
|
option.String("name", "username", arg.Argument),
|
||||||
|
option.String("password", "user pass", option.Short('p')),
|
||||||
|
),
|
||||||
|
option.String("url", "url", option.Short('u'), option.Slice),
|
||||||
|
option.Duration("timeout", "timeout", option.Short('t'), option.Slice),
|
||||||
|
option.Time("start-at", "start at", option.Default(test.Time("2010-01-02T15:04:05Z"))),
|
||||||
|
group.New("end", "end at",
|
||||||
|
option.Time("after", "after", option.Slice),
|
||||||
|
proto.New("service", "service after",
|
||||||
|
option.Time("after", "after"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
return def
|
||||||
|
}
|
||||||
@@ -8,10 +8,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitoa.ru/go-4devs/config"
|
"gitoa.ru/go-4devs/config"
|
||||||
"gitoa.ru/go-4devs/config/definition"
|
|
||||||
"gitoa.ru/go-4devs/config/definition/group"
|
|
||||||
"gitoa.ru/go-4devs/config/definition/option"
|
|
||||||
"gitoa.ru/go-4devs/config/definition/proto"
|
|
||||||
"gitoa.ru/go-4devs/config/provider/arg"
|
"gitoa.ru/go-4devs/config/provider/arg"
|
||||||
"gitoa.ru/go-4devs/config/test"
|
"gitoa.ru/go-4devs/config/test"
|
||||||
"gitoa.ru/go-4devs/config/test/require"
|
"gitoa.ru/go-4devs/config/test/require"
|
||||||
@@ -52,7 +48,7 @@ func TestProviderBind(t *testing.T) {
|
|||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
"-p 8080",
|
"-l 8080",
|
||||||
"--config=config.hcl",
|
"--config=config.hcl",
|
||||||
"-u http://4devs.io",
|
"-u http://4devs.io",
|
||||||
"--url=https://4devs.io",
|
"--url=https://4devs.io",
|
||||||
@@ -84,22 +80,7 @@ func TestProviderBind(t *testing.T) {
|
|||||||
func testVariables(t *testing.T) config.Variables {
|
func testVariables(t *testing.T) config.Variables {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
def := definition.New()
|
return config.NewVars(testOptions(t).Options()...)
|
||||||
def.Add(
|
|
||||||
option.Int("listen", "listen", option.Short('p')),
|
|
||||||
option.String("config", "config"),
|
|
||||||
option.String("url", "url", option.Short('u'), option.Slice),
|
|
||||||
option.Duration("timeout", "timeout", option.Short('t'), option.Slice),
|
|
||||||
option.Time("start-at", "start at"),
|
|
||||||
group.New("end", "end at",
|
|
||||||
option.Time("after", "after", option.Slice),
|
|
||||||
proto.New("service", "service after",
|
|
||||||
option.Time("after", "after"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
return config.NewVars(def.Options()...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Duration struct {
|
type Duration struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user