(t *testing.T)
| 233 | } |
| 234 | |
| 235 | func TestFirstStringOf(t *testing.T) { |
| 236 | getAppSet := func() (*cli.App, *flag.FlagSet) { |
| 237 | app := &cli.App{} |
| 238 | set := flag.NewFlagSet("contrive", 0) |
| 239 | return app, set |
| 240 | } |
| 241 | tests := []struct { |
| 242 | name string |
| 243 | getContext func() *cli.Context |
| 244 | inputs []string |
| 245 | want string |
| 246 | wantName string |
| 247 | }{ |
| 248 | { |
| 249 | name: "no-flags-empty", |
| 250 | getContext: func() *cli.Context { |
| 251 | app, set := getAppSet() |
| 252 | //_ = set.String("ca-url", "", "") |
| 253 | return cli.NewContext(app, set, nil) |
| 254 | }, |
| 255 | inputs: []string{"foo", "bar"}, |
| 256 | want: "", |
| 257 | wantName: "foo", |
| 258 | }, |
| 259 | { |
| 260 | name: "return-first-set-flag", |
| 261 | getContext: func() *cli.Context { |
| 262 | app, set := getAppSet() |
| 263 | _ = set.String("foo", "", "") |
| 264 | _ = set.String("bar", "", "") |
| 265 | _ = set.String("baz", "", "") |
| 266 | ctx := cli.NewContext(app, set, nil) |
| 267 | ctx.Set("bar", "test1") |
| 268 | ctx.Set("baz", "test2") |
| 269 | return ctx |
| 270 | }, |
| 271 | inputs: []string{"foo", "bar", "baz"}, |
| 272 | want: "test1", |
| 273 | wantName: "bar", |
| 274 | }, |
| 275 | { |
| 276 | name: "return-first-default-flag", |
| 277 | getContext: func() *cli.Context { |
| 278 | app, set := getAppSet() |
| 279 | _ = set.String("foo", "", "") |
| 280 | _ = set.String("bar", "", "") |
| 281 | _ = set.String("baz", "test1", "") |
| 282 | ctx := cli.NewContext(app, set, nil) |
| 283 | return ctx |
| 284 | }, |
| 285 | inputs: []string{"foo", "bar", "baz"}, |
| 286 | want: "test1", |
| 287 | wantName: "baz", |
| 288 | }, |
| 289 | { |
| 290 | name: "all-empty", |
| 291 | getContext: func() *cli.Context { |
| 292 | app, set := getAppSet() |
nothing calls this directly
no test coverage detected
searching dependent graphs…