MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / TestAddFlags

Function TestAddFlags

cmd/controller/options/options_test.go:31–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestAddFlags(t *testing.T) {
32 s := NewOptions()
33 fs := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
34 s.AddFlags(fs)
35 args := []string{
36 "--maxprocs=10",
37 "--repository-endpoint=http://127.0.0.1:3030",
38 "--repository-version=v1/ote",
39 "--repository-auth-type=cloud",
40 "--repository-auth-params={\"ak\":\"aaa\", \"sk\": \"bbb\"}",
41 "--http-enhanced=true",
42 }
43 fs.Parse(args)
44 fmt.Printf("%+v", s)
45 expected := NewOptions()
46 expected.GoMaxProcs = 10
47 expected.RepositoryOptions = &registry.Options{
48 Endpoint: "http://127.0.0.1:3030",
49 Version: "v1/ote",
50 Auth: &registry.AuthOption{
51 Name: "cloud",
52 ParamStr: "{\"ak\":\"aaa\", \"sk\": \"bbb\"}",
53 },
54 }
55 expected.HTTPEnhanced = true
56 if !reflect.DeepEqual(expected, s) {
57 t.Errorf("Got different run options than expected.")
58 }
59}

Callers

nothing calls this directly

Calls 3

AddFlagsMethod · 0.95
ErrorfMethod · 0.80
NewOptionsFunction · 0.70

Tested by

no test coverage detected