osascript_parse_test.go RawHistoryFolder

1package clipboard
2
3import (
4	"bytes"
5	"testing"
6)
7
8func TestParseOSAData(t *testing.T) {
9	tests := []struct {
10		name    string
11		output  string
12		class   string
13		want    []byte
14		wantErr bool
15	}{
16		{
17			name:   "png data",
18			output: "«data PNGf89504E470D0A1A0A»\n",
19			class:  "PNGf",
20			want:   []byte{0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a},
21		},
22		{
23			name:   "jpeg data",
24			output: "  «data JPEGffd8ffe000104a464946»  ",
25			class:  "JPEG",
26			want:   []byte{0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46},
27		},
28		{
29			name:    "missing data wrapper",
30			output:  "PNGf89504E47",
31			class:   "PNGf",
32			wantErr: true,
33		},
34		{
35			name:    "trailing output",
36			output:  "«data PNGf89504E47» unexpected",
37			class:   "PNGf",
38			wantErr: true,
39		},
40		{
41			name:    "wrong data class",
42			output:  "«data JPEGffd8»",
43			class:   "PNGf",
44			wantErr: true,
45		},
46		{
47			name:    "missing hex data",
48			output:  "«data PNGf»",
49			class:   "PNGf",
50			wantErr: true,
51		},
52		{
53			name:    "odd length hex data",
54			output:  "«data PNGf895»",
55			class:   "PNGf",
56			wantErr: true,
57		},
58		{
59			name:    "invalid hex data",
60			output:  "«data PNGf89504ZZ»",
61			class:   "PNGf",
62			wantErr: true,
63		},
64	}
65
66	for _, tt := range tests {
67		t.Run(tt.name, func(t *testing.T) {
68			got, err := parseOSAData(tt.output, tt.class)
69			if tt.wantErr {
70				if err == nil {
71					t.Fatal("parseOSAData() error = nil, want error")
72				}
73				return
74			}
75			if err != nil {
76				t.Fatalf("parseOSAData() error = %v", err)
77			}
78			if !bytes.Equal(got, tt.want) {
79				t.Fatalf("parseOSAData() = %x, want %x", got, tt.want)
80			}
81		})
82	}
83}

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 12

Tags 11

↑↓ moveenter openesc close