v2.14.0 5e11a00

run_backup_test.go RawHistoryFolder

1package app
2
3import (
4	"testing"
5
6	"github.com/stretchr/testify/assert"
7	"github.com/stretchr/testify/require"
8)
9
10func TestValidateBackupRetentionRejectsNegativeValues(t *testing.T) {
11	tests := []struct {
12		name string
13		set  func(*Config)
14		err  string
15	}{
16		{
17			name: "hourly",
18			set: func(cfg *Config) {
19				cfg.Backups.Retention.Hourly = -1
20			},
21			err: "backups.retention.hourly",
22		},
23		{
24			name: "daily",
25			set: func(cfg *Config) {
26				cfg.Backups.Retention.Daily = -1
27			},
28			err: "backups.retention.daily",
29		},
30		{
31			name: "weekly",
32			set: func(cfg *Config) {
33				cfg.Backups.Retention.Weekly = -1
34			},
35			err: "backups.retention.weekly",
36		},
37		{
38			name: "monthly",
39			set: func(cfg *Config) {
40				cfg.Backups.Retention.Monthly = -1
41			},
42			err: "backups.retention.monthly",
43		},
44	}
45
46	for _, tt := range tests {
47		t.Run(tt.name, func(t *testing.T) {
48			var cfg Config
49			tt.set(&cfg)
50
51			_, err := validateBackupRetention(cfg)
52			require.Error(t, err)
53			assert.Contains(t, err.Error(), tt.err)
54		})
55	}
56}
57
58func TestValidateBackupRetentionAcceptsZeroAndPositiveValues(t *testing.T) {
59	t.Run("positive values", func(t *testing.T) {
60		var cfg Config
61		cfg.Backups.Retention.Hourly = 1
62		cfg.Backups.Retention.Daily = 7
63		cfg.Backups.Retention.Weekly = 4
64		cfg.Backups.Retention.Monthly = 12
65
66		retention, err := validateBackupRetention(cfg)
67		require.NoError(t, err)
68		assert.Equal(t, 1, retention.Hourly)
69		assert.Equal(t, 7, retention.Daily)
70		assert.Equal(t, 4, retention.Weekly)
71		assert.Equal(t, 12, retention.Monthly)
72	})
73
74	t.Run("zero values", func(t *testing.T) {
75		var cfg Config
76		cfg.Backups.Retention.Hourly = 0
77		cfg.Backups.Retention.Daily = 0
78		cfg.Backups.Retention.Weekly = 0
79		cfg.Backups.Retention.Monthly = 0
80
81		retention, err := validateBackupRetention(cfg)
82		require.NoError(t, err)
83		assert.Equal(t, 0, retention.Hourly)
84		assert.Equal(t, 0, retention.Daily)
85		assert.Equal(t, 0, retention.Weekly)
86		assert.Equal(t, 0, retention.Monthly)
87	})
88}

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