本文整理汇总了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)
}