Fix errcheck warnings

Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
z1cheng 2023-06-28 16:10:39 +00:00 committed by k8s-infra-cherrypick-robot
parent 236a41a23b
commit 2bbd69e0d9
27 changed files with 207 additions and 70 deletions

View file

@ -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 {