main 6af0a61

bootloader_test.go RawHistoryFolder

1package bootloader
2
3import (
4	"testing"
5)
6
7func TestNewBootloader_Valid(t *testing.T) {
8	bootloader, err := NewBootloader(BootloaderTypeLimine, 0, "ArchUp")
9
10	if err != nil {
11		t.Fatalf("expected no error, got %v", err)
12	}
13
14	if bootloader.Type() != BootloaderTypeLimine {
15		t.Errorf("expected Limine type")
16	}
17
18	if bootloader.Timeout() != 0 {
19		t.Errorf("expected timeout 0")
20	}
21
22	if bootloader.Branding() != "ArchUp" {
23		t.Errorf("expected branding ArchUp")
24	}
25}
26
27func TestNewBootloader_InvalidTimeout(t *testing.T) {
28	tests := []struct {
29		name      string
30		timeout   int
31		shouldErr bool
32	}{
33		{"negative timeout", -1, true},
34		{"zero timeout", 0, false},
35		{"valid timeout", 5, false},
36		{"max timeout", 600, false},
37		{"exceed max", 601, true},
38	}
39
40	for _, tt := range tests {
41		t.Run(tt.name, func(t *testing.T) {
42			_, err := NewBootloader(BootloaderTypeLimine, tt.timeout, "Test")
43			if (err != nil) != tt.shouldErr {
44				t.Errorf("expected error=%v, got %v", tt.shouldErr, err)
45			}
46		})
47	}
48}
49
50func TestNewBootloader_InvalidBranding(t *testing.T) {
51	tests := []struct {
52		name      string
53		branding  string
54		shouldErr bool
55	}{
56		{"empty branding", "", true},
57		{"valid branding", "MyBrand", false},
58		{"too long", "a" + string(make([]byte, 100)), true},
59	}
60
61	for _, tt := range tests {
62		t.Run(tt.name, func(t *testing.T) {
63			_, err := NewBootloader(BootloaderTypeLimine, 0, tt.branding)
64			if (err != nil) != tt.shouldErr {
65				t.Errorf("expected error=%v, got %v", tt.shouldErr, err)
66			}
67		})
68	}
69}
70
71func TestBootloaderType_String(t *testing.T) {
72	tests := []struct {
73		btype BootloaderType
74		want  string
75	}{
76		{BootloaderTypeLimine, "Limine"},
77	}
78
79	for _, tt := range tests {
80		if got := tt.btype.String(); got != tt.want {
81			t.Errorf("expected %s, got %s", tt.want, got)
82		}
83	}
84}
85
86func TestBootloader_IsLimine(t *testing.T) {
87	limine, _ := NewBootloader(BootloaderTypeLimine, 0, "Test")
88
89	if !limine.IsLimine() {
90		t.Error("expected Limine")
91	}
92}
93
94func TestBootloader_Equals(t *testing.T) {
95	b1, _ := NewBootloader(BootloaderTypeLimine, 0, "Test")
96	b2, _ := NewBootloader(BootloaderTypeLimine, 0, "Test")
97
98	if !b1.Equals(b2) {
99		t.Error("expected equal bootloaders")
100	}
101
102	if b1.Equals(nil) {
103		t.Error("expected nil to not be equal")
104	}
105}

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 0

    ↑↓ moveenter openesc close