| 4141 | } |
| 4142 | |
| 4143 | func TestCommand_Timestamp(t *testing.T) { |
| 4144 | t1 := time.Time{}.Add(12 * time.Second) |
| 4145 | t2 := time.Time{}.Add(13 * time.Second) |
| 4146 | |
| 4147 | cmd := &Command{ |
| 4148 | Name: "hello", |
| 4149 | Flags: []Flag{ |
| 4150 | &TimestampFlag{ |
| 4151 | Name: "myflag", |
| 4152 | Value: t1, |
| 4153 | }, |
| 4154 | }, |
| 4155 | Action: func(ctx context.Context, c *Command) error { |
| 4156 | return nil |
| 4157 | }, |
| 4158 | } |
| 4159 | |
| 4160 | pCmd := &Command{ |
| 4161 | Flags: []Flag{ |
| 4162 | &TimestampFlag{ |
| 4163 | Name: "top-flag", |
| 4164 | Value: t2, |
| 4165 | }, |
| 4166 | }, |
| 4167 | Commands: []*Command{ |
| 4168 | cmd, |
| 4169 | }, |
| 4170 | } |
| 4171 | |
| 4172 | err := pCmd.Run(context.Background(), []string{"foo", "hello"}) |
| 4173 | assert.NoError(t, err) |
| 4174 | |
| 4175 | r := require.New(t) |
| 4176 | r.Equal(t1, cmd.Timestamp("myflag")) |
| 4177 | r.Equal(t2, cmd.Timestamp("top-flag")) |
| 4178 | } |
| 4179 | |
| 4180 | func TestCommand_String(t *testing.T) { |
| 4181 | pCmd := &Command{ |