mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-09-21 02:30:14 +00:00
test(agentcompat): add process supervision harness
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
//go:build linux
|
||||
|
||||
package process
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestProcessHasOpenPathTogglesWithDescriptorLifecycle(t *testing.T) {
|
||||
// Given
|
||||
path := filepath.Join(t.TempDir(), "dashboard.sqlite-journal")
|
||||
require.NoError(t, os.WriteFile(path, []byte("journal"), 0o600))
|
||||
file, err := os.Open(path)
|
||||
require.NoError(t, err)
|
||||
|
||||
// When
|
||||
held, err := ProcessHasOpenPath(os.Getpid(), path)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, file.Close())
|
||||
released, err := ProcessHasOpenPath(os.Getpid(), path)
|
||||
|
||||
// Then
|
||||
require.NoError(t, err)
|
||||
require.True(t, held)
|
||||
require.False(t, released)
|
||||
}
|
||||
Reference in New Issue
Block a user