Fix errcheck warnings
Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
236a41a23b
commit
2bbd69e0d9
27 changed files with 207 additions and 70 deletions
|
|
@ -42,9 +42,9 @@ func (f *FakeProcess) exiterFunc(code int) {
|
|||
f.exitCode = code
|
||||
}
|
||||
|
||||
func sendDelayedSignal(delay time.Duration) {
|
||||
func sendDelayedSignal(delay time.Duration) error {
|
||||
time.Sleep(delay * time.Second)
|
||||
syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
||||
return syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
||||
}
|
||||
|
||||
func TestHandleSigterm(t *testing.T) {
|
||||
|
|
@ -66,7 +66,12 @@ func TestHandleSigterm(t *testing.T) {
|
|||
for _, tt := range tests {
|
||||
process := &FakeProcess{shouldError: tt.shouldError}
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
go sendDelayedSignal(2) // Send a signal after 2 seconds
|
||||
go func() {
|
||||
err := sendDelayedSignal(2) // Send a signal after 2 seconds
|
||||
if err != nil {
|
||||
t.Errorf("error sending delayed signal: %v", err)
|
||||
}
|
||||
}()
|
||||
HandleSigterm(process, tt.delay, process.exiterFunc)
|
||||
})
|
||||
if tt.shouldError && process.exitCode != 1 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue