Fixed time unit loss problem after converting time (#3004)

The time unit of 'function.Spec.FunctionTimeout' is second, but after conversion from the function time.Duration, the unit becomes nanosecond. So it needs to be repaired.

Signed-off-by: waitstory <waitstory@163.com>
This commit is contained in:
waitstory
2024-08-30 16:54:41 +05:30
committed by GitHub
parent ce49eb3e18
commit 11baffc92c
+2 -2
View File
@@ -108,7 +108,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
)
fnTestTimeout := input.Duration(flagkey.FnTestTimeout)
fnSpecTimeout := time.Duration(function.Spec.FunctionTimeout)
fnSpecTimeout := time.Duration(function.Spec.FunctionTimeout) * time.Second
if input.IsSet(flagkey.FnTestTimeout) && (fnTestTimeout < fnSpecTimeout) {
reqTimeout = fnTestTimeout
@@ -121,7 +121,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
ctx = input.Context()
} else {
var closeCtx context.CancelFunc
ctx, closeCtx = context.WithTimeoutCause(input.Context(), reqTimeout*time.Second, fmt.Errorf("function request timeout (%d)s exceeded", reqTimeout))
ctx, closeCtx = context.WithTimeoutCause(input.Context(), reqTimeout, fmt.Errorf("function request timeout (%d)s exceeded", reqTimeout))
defer closeCtx()
}