main ae76d4b

mocks_test.go RawHistoryFolder

1package analyzer
2
3import (
4	"os"
5	"path/filepath"
6	"testing"
7)
8
9func TestIsTestDoubleName(t *testing.T) {
10	tests := []struct {
11		name string
12		want bool
13	}{
14		{name: "fakeUserRepository", want: true},
15		{name: "FakeUserRepository", want: true},
16		{name: "stubClock", want: true},
17		{name: "StubClock", want: true},
18		{name: "user_fake", want: true},
19		{name: "fake", want: true},
20		{name: "stub", want: true},
21		{name: "StubbornHandler", want: false},
22		{name: "stubbornHandler", want: false},
23		{name: "FakeoutService", want: false},
24		{name: "fakeoutService", want: false},
25		{name: "outfake", want: false},
26	}
27	for _, tt := range tests {
28		t.Run(tt.name, func(t *testing.T) {
29			if got := isTestDoubleName(tt.name); got != tt.want {
30				t.Fatalf("isTestDoubleName(%q) = %v, want %v", tt.name, got, tt.want)
31			}
32		})
33	}
34}
35
36func TestDeclaredTypes(t *testing.T) {
37	tests := []struct {
38		name   string
39		source string
40		want   []string
41	}{
42		{
43			name: "plain and generic declarations",
44			source: `package mocks
45
46type MockCache[K comparable, V any] struct{}
47type (
48	MockUserRepository struct{}
49	helper string
50)
51`,
52			want: []string{"MockCache", "MockUserRepository", "helper"},
53		},
54	}
55	for _, tt := range tests {
56		t.Run(tt.name, func(t *testing.T) {
57			path := filepath.Join(t.TempDir(), "mocks.go")
58			if err := os.WriteFile(path, []byte(tt.source), 0o600); err != nil {
59				t.Fatal(err)
60			}
61			got := declaredTypes(path)
62			if len(got) != len(tt.want) {
63				t.Fatalf("declaredTypes() = %#v, want %#v", got, tt.want)
64			}
65			for i := range got {
66				if got[i] != tt.want[i] {
67					t.Fatalf("declaredTypes() = %#v, want %#v", got, tt.want)
68				}
69			}
70		})
71	}
72}

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 5

↑↓ moveenter openesc close