prune_scheduler_test.go RawHistoryFolder

1package app
2
3import (
4	"context"
5	"testing"
6
7	"github.com/bnema/zerowrap"
8	"github.com/stretchr/testify/assert"
9	"github.com/stretchr/testify/require"
10
11	"github.com/bnema/gordon/internal/usecase/images"
12)
13
14// TestStartImagePruneSchedulerRegistersWhenAppsExist proves the
15// scheduler is no longer disabled by app state: a configured schedule
16// registers even though the server has apps, and the job runs the same
17// use case as manual execution.
18func TestStartImagePruneSchedulerRegistersWhenAppsExist(t *testing.T) {
19	cfg := Config{}
20	cfg.Images.Prune.Enabled = true
21	cfg.Images.Prune.Schedule = "daily"
22	cfg.Images.Prune.KeepLast = 3
23
24	svc := &services{imageSvc: images.NewService(nil, nil, nil, zerowrap.Default())}
25
26	scheduler, err := startImagePruneScheduler(context.Background(), cfg, svc, zerowrap.Default(), nil)
27	require.NoError(t, err)
28	require.NotNil(t, scheduler, "a configured schedule must register regardless of app state")
29	assert.NotEmpty(t, scheduler.List())
30}
31
32func TestStartImagePruneSchedulerDisabledWhenNotConfigured(t *testing.T) {
33	svc := &services{imageSvc: images.NewService(nil, nil, nil, zerowrap.Default())}
34
35	scheduler, err := startImagePruneScheduler(context.Background(), Config{}, svc, zerowrap.Default(), nil)
36	require.NoError(t, err)
37	assert.Nil(t, scheduler)
38}
39
40func TestStartImagePruneSchedulerRejectsNegativeKeepLast(t *testing.T) {
41	cfg := Config{}
42	cfg.Images.Prune.Enabled = true
43	cfg.Images.Prune.Schedule = "daily"
44	cfg.Images.Prune.KeepLast = 3
45
46	svc := &services{imageSvc: images.NewService(nil, nil, nil, zerowrap.Default())}
47	scheduler, err := startImagePruneScheduler(context.Background(), cfg, svc, zerowrap.Default(), func() int { return -1 })
48	require.Error(t, err)
49	assert.Nil(t, scheduler)
50}

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 7

Tags 106

↑↓ moveenter openesc close