本文整理匯總了Golang中github.com/aws/amazon-ssm-agent/agent/task.CancelFlag.Set方法的典型用法代碼示例。如果您正苦於以下問題:Golang CancelFlag.Set方法的具體用法?Golang CancelFlag.Set怎麽用?Golang CancelFlag.Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aws/amazon-ssm-agent/agent/task.CancelFlag
的用法示例。
在下文中一共展示了CancelFlag.Set方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: testCommandInvokerCancel
func testCommandInvokerCancel(t *testing.T, invoke CommandInvoker, cancelFlag task.CancelFlag, testCase TestCase) {
go func() {
time.Sleep(100 * time.Millisecond)
cancelFlag.Set(task.Canceled)
}()
start := time.Now()
stdout, stderr, exitCode, errs := invoke(testCase.Commands)
duration := time.Since(start)
// test that the job returned before the normal time
assert.True(t, duration.Seconds() <= cancelWaitTimeoutSeconds, "The command took too long to kill (%v)!", duration)
// test that we receive kill exception
assert.Equal(t, len(errs), 1)
assert.IsType(t, &exec.ExitError{}, errs[0])
assertReaderEquals(t, testCase.ExpectedStdout, stdout)
assertReaderEquals(t, testCase.ExpectedStderr, stderr)
assert.Equal(t, exitCode, testCase.ExpectedExitCode)
}