test: add sysutil and cache tests

- Add RestartService tests (pkg/sysutil)
- Add decodeRedisValue and normalizeRedisValue tests (cache/l2.go)
This commit is contained in:
Your Name
2026-05-29 17:38:48 +08:00
parent 281811e80b
commit cd5dae4778
2 changed files with 104 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package sysutil
import (
"runtime"
"testing"
"github.com/stretchr/testify/require"
)
func TestRestartService_NonLinux(t *testing.T) {
// On non-Linux systems, RestartService should return nil without exiting
if runtime.GOOS == "linux" {
t.Skip("Skipping non-Linux test on Linux")
}
err := RestartService()
require.NoError(t, err)
}
func TestRestartServiceAsync_NonLinux(t *testing.T) {
// On non-Linux systems, RestartServiceAsync should not panic
if runtime.GOOS == "linux" {
t.Skip("Skipping non-Linux test on Linux")
}
// Should not panic
RestartServiceAsync()
}