v2.31.0-dev6 8056b57

image_test.go RawHistoryFolder

1package validation
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/assert"
7)
8
9func TestParseImageReference(t *testing.T) {
10	tests := []struct {
11		name     string
12		imageRef string
13		wantName string
14		wantRef  string
15	}{
16		{
17			name:     "simple image with latest tag",
18			imageRef: "myapp:latest",
19			wantName: "myapp",
20			wantRef:  "latest",
21		},
22		{
23			name:     "simple image with custom tag",
24			imageRef: "myapp:v1.0.0",
25			wantName: "myapp",
26			wantRef:  "v1.0.0",
27		},
28		{
29			name:     "simple image with digest",
30			imageRef: "myapp@sha256:abc123def456",
31			wantName: "myapp",
32			wantRef:  "sha256:abc123def456",
33		},
34		{
35			name:     "registry with image and tag",
36			imageRef: "registry.example.com/myapp:latest",
37			wantName: "registry.example.com/myapp",
38			wantRef:  "latest",
39		},
40		{
41			name:     "registry with port and image and tag",
42			imageRef: "registry.example.com:5000/myapp:v1.0",
43			wantName: "registry.example.com:5000/myapp",
44			wantRef:  "v1.0",
45		},
46		{
47			name:     "registry with port, image, and digest",
48			imageRef: "registry.example.com:5000/myapp@sha256:abc123",
49			wantName: "registry.example.com:5000/myapp",
50			wantRef:  "sha256:abc123",
51		},
52		{
53			name:     "simple image without tag (defaults to latest)",
54			imageRef: "myapp",
55			wantName: "myapp",
56			wantRef:  "latest",
57		},
58		{
59			name:     "registry with image without tag",
60			imageRef: "registry.example.com/myapp",
61			wantName: "registry.example.com/myapp",
62			wantRef:  "latest",
63		},
64		{
65			name:     "nested path image with tag",
66			imageRef: "registry.example.com/path/to/myapp:latest",
67			wantName: "registry.example.com/path/to/myapp",
68			wantRef:  "latest",
69		},
70		{
71			name:     "localhost registry with port",
72			imageRef: "localhost:5000/myapp:latest",
73			wantName: "localhost:5000/myapp",
74			wantRef:  "latest",
75		},
76		{
77			name:     "IP address registry with port",
78			imageRef: "192.168.1.100:5000/myapp:latest",
79			wantName: "192.168.1.100:5000/myapp",
80			wantRef:  "latest",
81		},
82	}
83
84	for _, tt := range tests {
85		t.Run(tt.name, func(t *testing.T) {
86			gotName, gotRef := ParseImageReference(tt.imageRef)
87			assert.Equal(t, tt.wantName, gotName, "name mismatch")
88			assert.Equal(t, tt.wantRef, gotRef, "reference mismatch")
89		})
90	}
91}

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