main 5041353

engine_context_test.go RawHistoryFolder

1package port_test
2
3import (
4	"testing"
5
6	"github.com/bnema/dumber/internal/application/port"
7	"github.com/stretchr/testify/assert"
8)
9
10func TestMemoryPressureConfig_IsConfigured(t *testing.T) {
11	tests := []struct {
12		name     string
13		config   *port.MemoryPressureConfig
14		expected bool
15	}{
16		{
17			name:     "nil config",
18			config:   nil,
19			expected: false,
20		},
21		{
22			name:     "empty config",
23			config:   &port.MemoryPressureConfig{},
24			expected: false,
25		},
26		{
27			name: "only MemoryLimitMB set",
28			config: &port.MemoryPressureConfig{
29				MemoryLimitMB: 1024,
30			},
31			expected: true,
32		},
33		{
34			name: "only PollIntervalSec set",
35			config: &port.MemoryPressureConfig{
36				PollIntervalSec: 30.0,
37			},
38			expected: true,
39		},
40		{
41			name: "only ConservativeThreshold set",
42			config: &port.MemoryPressureConfig{
43				ConservativeThreshold: 0.33,
44			},
45			expected: true,
46		},
47		{
48			name: "only StrictThreshold set",
49			config: &port.MemoryPressureConfig{
50				StrictThreshold: 0.5,
51			},
52			expected: true,
53		},
54		{
55			name: "all defaults (unset)",
56			config: &port.MemoryPressureConfig{
57				MemoryLimitMB:         0,
58				PollIntervalSec:       0,
59				ConservativeThreshold: 0,
60				StrictThreshold:       0,
61			},
62			expected: false,
63		},
64		{
65			name: "fully configured",
66			config: &port.MemoryPressureConfig{
67				MemoryLimitMB:         2048,
68				PollIntervalSec:       15.0,
69				ConservativeThreshold: 0.25,
70				StrictThreshold:       0.6,
71			},
72			expected: true,
73		},
74	}
75
76	for _, tt := range tests {
77		t.Run(tt.name, func(t *testing.T) {
78			result := tt.config.IsConfigured()
79			assert.Equal(t, tt.expected, result)
80		})
81	}
82}
83
84func TestEngineOptions_IsWebProcessMemoryConfigured(t *testing.T) {
85	tests := []struct {
86		name     string
87		opts     port.EngineOptions
88		expected bool
89	}{
90		{
91			name:     "nil WebProcessMemory",
92			opts:     port.EngineOptions{},
93			expected: false,
94		},
95		{
96			name: "empty WebProcessMemory",
97			opts: port.EngineOptions{
98				WebProcessMemory: &port.MemoryPressureConfig{},
99			},
100			expected: false,
101		},
102		{
103			name: "configured WebProcessMemory",
104			opts: port.EngineOptions{
105				WebProcessMemory: &port.MemoryPressureConfig{
106					MemoryLimitMB: 1024,
107				},
108			},
109			expected: true,
110		},
111	}
112
113	for _, tt := range tests {
114		t.Run(tt.name, func(t *testing.T) {
115			result := tt.opts.WebProcessMemory.IsConfigured()
116			assert.Equal(t, tt.expected, result)
117		})
118	}
119}
120
121func TestEngineOptions_IsNetworkProcessMemoryConfigured(t *testing.T) {
122	tests := []struct {
123		name     string
124		opts     port.EngineOptions
125		expected bool
126	}{
127		{
128			name:     "nil NetworkProcessMemory",
129			opts:     port.EngineOptions{},
130			expected: false,
131		},
132		{
133			name: "empty NetworkProcessMemory",
134			opts: port.EngineOptions{
135				NetworkProcessMemory: &port.MemoryPressureConfig{},
136			},
137			expected: false,
138		},
139		{
140			name: "configured NetworkProcessMemory",
141			opts: port.EngineOptions{
142				NetworkProcessMemory: &port.MemoryPressureConfig{
143					PollIntervalSec: 20.0,
144				},
145			},
146			expected: true,
147		},
148	}
149
150	for _, tt := range tests {
151		t.Run(tt.name, func(t *testing.T) {
152			result := tt.opts.NetworkProcessMemory.IsConfigured()
153			assert.Equal(t, tt.expected, result)
154		})
155	}
156}

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 8

Tags 42

↑↓ moveenter openesc close