v2.31.0-dev8 ec8c5b9

run_pid_test.go RawHistoryFolder

1package app
2
3import (
4	"os"
5	"path/filepath"
6	"strconv"
7	"testing"
8
9	"github.com/stretchr/testify/assert"
10	"github.com/stretchr/testify/require"
11)
12
13func TestFindRunningPidFileInLocations_PrefersLiveProcessOverStale(t *testing.T) {
14	tmpDir := t.TempDir()
15	staleFile := filepath.Join(tmpDir, "stale.pid")
16	liveFile := filepath.Join(tmpDir, "live.pid")
17
18	require.NoError(t, os.WriteFile(staleFile, []byte("999999"), 0600))
19	myPid := os.Getpid()
20	require.NoError(t, os.WriteFile(liveFile, []byte(strconv.Itoa(myPid)), 0600))
21
22	path, pid, err := findRunningPidFileInLocations([]string{staleFile, liveFile})
23	require.NoError(t, err)
24	assert.Equal(t, liveFile, path)
25	assert.Equal(t, myPid, pid)
26
27	_, statErr := os.Stat(staleFile)
28	assert.True(t, os.IsNotExist(statErr))
29}
30
31func TestFindRunningPidFileInLocations_RemovesInvalidAndReturnsError(t *testing.T) {
32	tmpDir := t.TempDir()
33	invalidFile := filepath.Join(tmpDir, "invalid.pid")
34
35	require.NoError(t, os.WriteFile(invalidFile, []byte("not-a-pid"), 0600))
36
37	_, _, err := findRunningPidFileInLocations([]string{invalidFile})
38	require.Error(t, err)
39	assert.Contains(t, err.Error(), "stale gordon PID file")
40
41	_, statErr := os.Stat(invalidFile)
42	assert.True(t, os.IsNotExist(statErr))
43}
44
45func TestFindRunningPidFileInLocations_NoFiles(t *testing.T) {
46	_, _, err := findRunningPidFileInLocations([]string{})
47	require.Error(t, err)
48	assert.Contains(t, err.Error(), "gordon PID file not found")
49}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 7

Tags 106

↑↓ moveenter openesc close