MCPcopy
hub / github.com/urfave/cli / TestCommand_lookupFlag

Function TestCommand_lookupFlag

command_test.go:4494–4522  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4492}
4493
4494func TestCommand_lookupFlag(t *testing.T) {
4495 pCmd := &Command{
4496 Flags: []Flag{
4497 &BoolFlag{
4498 Name: "top-flag",
4499 Value: true,
4500 },
4501 },
4502 }
4503 cmd := &Command{
4504 Flags: []Flag{
4505 &BoolFlag{
4506 Name: "local-flag",
4507 },
4508 },
4509 }
4510 _ = cmd.Run(context.Background(), []string{"--local-flag"})
4511 pCmd.Commands = []*Command{cmd}
4512 _ = pCmd.Run(context.Background(), []string{"--top-flag"})
4513
4514 r := require.New(t)
4515
4516 fs := cmd.lookupFlag("top-flag")
4517 r.Equal(pCmd.Flags[0], fs)
4518
4519 fs = cmd.lookupFlag("local-flag")
4520 r.Equal(cmd.Flags[0], fs)
4521 r.Nil(cmd.lookupFlag("frob"))
4522}
4523
4524func TestCommandAttributeAccessing(t *testing.T) {
4525 tdata := []struct {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.95
lookupFlagMethod · 0.95

Tested by

no test coverage detected