(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func 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 = ®istry.Options{ |
| 48 | Endpoint: "http://127.0.0.1:3030", |
| 49 | Version: "v1/ote", |
| 50 | Auth: ®istry.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 | } |
nothing calls this directly
no test coverage detected