v0.1.1 0e08fa2

runtime_test.go RawHistoryFolder

1package core
2
3import (
4	"testing"
5
6	portmocks "github.com/bnema/purego-pipewire/internal/ports/out/mocks"
7)
8
9func TestRuntimeInitRejectsDifferentCAPIAfterProcessWideInit(t *testing.T) {
10	api1 := portmocks.NewMockCAPI(t)
11	api2 := portmocks.NewMockCAPI(t)
12
13	api1.EXPECT().PWDeinit().Once()
14	api1.EXPECT().PWInit((*int32)(nil), (***byte)(nil)).Once()
15
16	r1 := NewRuntime(api1)
17	if err := r1.Init(); err != nil {
18		t.Fatalf("Init returned error: %v", err)
19	}
20	r2 := NewRuntime(api2)
21	if err := r2.Init(); err == nil {
22		t.Fatal("second Init returned nil error, want mismatch rejection")
23	}
24
25	r2.Deinit()
26	r1.Deinit()
27
28	api2.AssertNotCalled(t, "PWInit", (*int32)(nil), (***byte)(nil))
29	api2.AssertNotCalled(t, "PWDeinit")
30}
31
32func TestRuntimeInitRejectsNilCAPI(t *testing.T) {
33	r := NewRuntime(nil)
34	if err := r.Init(); err == nil {
35		t.Fatal("Init returned nil error, want nil CAPI rejection")
36	}
37
38	r.Deinit()
39}
40
41func TestRuntimeDeinitWaitsForLastInitializedRuntime(t *testing.T) {
42	api1 := portmocks.NewMockCAPI(t)
43
44	deinitCalls := 0
45	api1.EXPECT().PWInit((*int32)(nil), (***byte)(nil)).Once()
46	api1.EXPECT().PWDeinit().Run(func() {
47		deinitCalls++
48	}).Once()
49
50	r1 := NewRuntime(api1)
51	if err := r1.Init(); err != nil {
52		t.Fatalf("first Init returned error: %v", err)
53	}
54	r2 := NewRuntime(api1)
55	if err := r2.Init(); err != nil {
56		t.Fatalf("second Init returned error: %v", err)
57	}
58
59	r1.Deinit()
60	if deinitCalls != 0 {
61		t.Fatalf("PWDeinit called after first Deinit, want 0 calls before last runtime deinitializes")
62	}
63
64	NewRuntime(api1).Deinit()
65	if deinitCalls != 0 {
66		t.Fatalf("PWDeinit called after non-initialized runtime Deinit, want 0 calls before last runtime deinitializes")
67	}
68
69	r2.Deinit()
70	if deinitCalls != 1 {
71		t.Fatalf("PWDeinit called %d times, want 1", deinitCalls)
72	}
73}

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 8

↑↓ moveenter openesc close