main 602baa7

requests_test.go RawHistoryFolder

1package xturbo_test
2
3import (
4	"bytes"
5	"encoding/binary"
6	"testing"
7
8	"bnema.dev/xturbo"
9	"bnema.dev/xturbo/internal/xtest"
10	"bnema.dev/xturbo/xfixes"
11	"bnema.dev/xturbo/xproto"
12)
13
14func TestRequestGoldens(t *testing.T) {
15	for _, tc := range []struct {
16		name   string
17		encode func(*xturbo.Buf, uint32) xturbo.Seq
18	}{
19		{"xproto/MapWindow", func(b *xturbo.Buf, id uint32) xturbo.Seq { return xproto.MapWindow(b, xproto.Window(id)) }},
20		{"xproto/GetGeometry", func(b *xturbo.Buf, id uint32) xturbo.Seq { return xproto.GetGeometry(b, xproto.Drawable(id)) }},
21		{"xfixes/QueryVersion", func(b *xturbo.Buf, _ uint32) xturbo.Seq { return xfixes.QueryVersion(b, 6, 0) }},
22	} {
23		t.Run(tc.name, func(t *testing.T) {
24			want, err := xtest.LoadHex("testdata/golden/" + tc.name + ".req.hex")
25			if err != nil {
26				t.Fatal(err)
27			}
28			b := xturbo.NewBuf(0)
29			var ext xturbo.ExtTable
30			ext.Set(xturbo.ExtXFixes, want[0], 0, 0)
31			b.Ext = &ext
32			id := binary.LittleEndian.Uint32(want[4:])
33			if tc.encode(b, id) != 1 || b.Err() != nil {
34				t.Fatalf("seq/err: %v", b.Err())
35			}
36			if !bytes.Equal(b.Bytes(), want) {
37				t.Fatalf("got %x want %x", b.Bytes(), want)
38			}
39		})
40	}
41}
42func TestMissingExtension(t *testing.T) {
43	for _, table := range []*xturbo.ExtTable{nil, {}} {
44		b := xturbo.NewBuf(0)
45		b.Ext = table
46		if xfixes.QueryVersion(b, 6, 0) != 0 || b.Err() != xturbo.ErrExtMissing || b.Len() != 0 || xproto.MapWindow(b, 1) != 0 {
47			t.Fatal("missing extension must fail sticky")
48		}
49	}
50}
51func TestAllocFixedRequests(t *testing.T) {
52	b := xturbo.NewBuf(0)
53	var ext xturbo.ExtTable
54	ext.Set(xturbo.ExtXFixes, 138, 0, 0)
55	b.Ext = &ext
56	if n := testing.AllocsPerRun(1000, func() { b.Reset(); xproto.MapWindow(b, 1); xproto.GetGeometry(b, 1); xfixes.QueryVersion(b, 6, 0) }); n != 0 {
57		t.Fatal(n)
58	}
59	if b.Err() != nil {
60		t.Fatal(b.Err())
61	}
62}

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 1

Tags 1

↑↓ moveenter openesc close