MCPcopy
hub / github.com/cloudflare/cloudflared / TestTryCreateLockFile_Success

Function TestTryCreateLockFile_Success

token/lockfile_test.go:81–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

79}
80
81func TestTryCreateLockFile_Success(t *testing.T) {
82 dir := t.TempDir()
83 path := filepath.Join(dir, "test.lock")
84
85 err := tryCreateLockFile(path)
86 require.NoError(t, err)
87
88 // verify the file contains valid JSON with our PID
89 data, err := os.ReadFile(path) // nolint: gosec
90 require.NoError(t, err)
91 var content lockContent
92 require.NoError(t, json.Unmarshal(data, &content))
93 assert.Equal(t, int32(os.Getpid()), content.PID) // nolint: gosec
94 assert.Positive(t, content.StartTime)
95}
96
97func TestTryCreateLockFile_AlreadyExists(t *testing.T) {
98 dir := t.TempDir()

Callers

nothing calls this directly

Calls 3

tryCreateLockFileFunction · 0.85
EqualMethod · 0.65
UnmarshalMethod · 0.45

Tested by

no test coverage detected