Change sleep 'time_in_seconds' to 'duration_in_seconds'
This commit is contained in:
parent
8af041fe44
commit
f5254c1c65
@ -102,9 +102,9 @@ func (ce *CommandExecutor) cmdEcho(ctx context.Context, logger zerolog.Logger, t
|
|||||||
// cmdSleep executes the "sleep" command.
|
// cmdSleep executes the "sleep" command.
|
||||||
func (ce *CommandExecutor) cmdSleep(ctx context.Context, logger zerolog.Logger, taskID TaskID, cmd api.Command) error {
|
func (ce *CommandExecutor) cmdSleep(ctx context.Context, logger zerolog.Logger, taskID TaskID, cmd api.Command) error {
|
||||||
|
|
||||||
sleepTime, ok := cmd.Settings["time_in_seconds"]
|
sleepTime, ok := cmd.Settings["duration_in_seconds"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("missing setting 'time_in_seconds'")
|
return errors.New("missing setting 'duration_in_seconds'")
|
||||||
}
|
}
|
||||||
|
|
||||||
var duration time.Duration
|
var duration time.Duration
|
||||||
@ -112,8 +112,8 @@ func (ce *CommandExecutor) cmdSleep(ctx context.Context, logger zerolog.Logger,
|
|||||||
case int:
|
case int:
|
||||||
duration = time.Duration(v) * time.Second
|
duration = time.Duration(v) * time.Second
|
||||||
default:
|
default:
|
||||||
log.Warn().Interface("time_in_seconds", v).Msg("bad type for setting 'time_in_seconds', expected int")
|
log.Warn().Interface("duration_in_seconds", v).Msg("bad type for setting 'duration_in_seconds', expected int")
|
||||||
return fmt.Errorf("bad type for setting 'time_in_seconds', expected int, not %v", v)
|
return fmt.Errorf("bad type for setting 'duration_in_seconds', expected int, not %v", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info().Str("duration", duration.String()).Msg("sleep")
|
log.Info().Str("duration", duration.String()).Msg("sleep")
|
||||||
|
@ -94,7 +94,7 @@ func TestCommandSleep(t *testing.T) {
|
|||||||
taskID := TaskID("90e9d656-e201-4ef0-b6b0-c80684fafa27")
|
taskID := TaskID("90e9d656-e201-4ef0-b6b0-c80684fafa27")
|
||||||
cmd := api.Command{
|
cmd := api.Command{
|
||||||
Name: "sleep",
|
Name: "sleep",
|
||||||
Settings: map[string]interface{}{"time_in_seconds": 47},
|
Settings: map[string]interface{}{"duration_in_seconds": 47},
|
||||||
}
|
}
|
||||||
|
|
||||||
timeBefore := clock.Now()
|
timeBefore := clock.Now()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user