v2.31.0-dev16 8d0a092

detect_test.go RawHistoryFolder

1package docker
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/assert"
7	"github.com/stretchr/testify/require"
8)
9
10func TestDetectRuntimeSocket_ExplicitPathTakesPrecedence(t *testing.T) {
11	result := DetectRuntimeSocket("/custom/sock")
12	assert.Equal(t, "/custom/sock", result.SocketPath)
13	assert.Equal(t, "explicit", result.Source)
14}
15
16func TestDetectRuntimeSocket_FallsBackToDockerHost(t *testing.T) {
17	t.Setenv("DOCKER_HOST", "unix:///tmp/test-docker.sock")
18	result := DetectRuntimeSocket("")
19	assert.Equal(t, "/tmp/test-docker.sock", result.SocketPath)
20	assert.Equal(t, "DOCKER_HOST", result.Source)
21}
22
23func TestDetectRuntimeSocket_EmptyDockerHostIgnored(t *testing.T) {
24	t.Setenv("DOCKER_HOST", "")
25	result := DetectRuntimeSocket("")
26	assert.NotEqual(t, "DOCKER_HOST", result.Source)
27}
28
29func TestDetectRuntimeSocket_NonUnixDockerHostPassedThrough(t *testing.T) {
30	t.Setenv("DOCKER_HOST", "tcp://localhost:2375")
31	result := DetectRuntimeSocket("")
32	assert.Equal(t, "", result.SocketPath)
33	assert.Equal(t, "DOCKER_HOST_passthrough", result.Source)
34}
35
36func TestParseUnixSocketPath(t *testing.T) {
37	tests := []struct {
38		input string
39		path  string
40		ok    bool
41	}{
42		{"unix:///var/run/docker.sock", "/var/run/docker.sock", true},
43		{"unix:///run/podman/podman.sock", "/run/podman/podman.sock", true},
44		{"tcp://localhost:2375", "", false},
45		{"/var/run/docker.sock", "/var/run/docker.sock", true},
46	}
47	for _, tt := range tests {
48		t.Run(tt.input, func(t *testing.T) {
49			path, ok := parseUnixSocketPath(tt.input)
50			assert.Equal(t, tt.ok, ok)
51			if ok {
52				assert.Equal(t, tt.path, path)
53			}
54		})
55	}
56}
57
58func TestNewRuntimeWithSocket_UsesExplicitHost(t *testing.T) {
59	rt, err := NewRuntimeWithSocket("/nonexistent/test.sock")
60	require.NoError(t, err)
61	require.NotNil(t, rt)
62	assert.Contains(t, rt.client.DaemonHost(), "/nonexistent/test.sock")
63}

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