mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
feat(reports): delete reports and configure retention (#3338)
This commit is contained in:
1 parent
93d1f8af46
commit
82abd03a37
106 files changed
+1457
-170
No files matched your search
@@ -978,6 +978,60 @@ describe('ConfigLoader', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('report retention settings', () => {
|
||||
beforeEach(() => {
|
||||
resetConfig();
|
||||
clearFluxerEnv();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetConfig();
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
|
||||
test('deletes reports for real after 365 days with no resolved-report rule by default', async () => {
|
||||
stubMinimalEnv();
|
||||
const config = await loadConfig();
|
||||
expect(config.report_retention).toEqual({days: 365, resolved_days: null, dry_run: false});
|
||||
});
|
||||
|
||||
test('reads both day settings and the dry run switch from the environment', async () => {
|
||||
stubMinimalEnv({
|
||||
FLUXER_REPORT_RETENTION_DAYS: '730',
|
||||
FLUXER_RESOLVED_REPORT_RETENTION_DAYS: ' 90 ',
|
||||
FLUXER_REPORT_RETENTION_DRY_RUN: 'TRUE',
|
||||
});
|
||||
const config = await loadConfig();
|
||||
expect(config.report_retention).toEqual({days: 730, resolved_days: 90, dry_run: true});
|
||||
});
|
||||
|
||||
test('an empty resolved-report setting leaves the rule off', async () => {
|
||||
stubMinimalEnv({FLUXER_RESOLVED_REPORT_RETENTION_DAYS: '', FLUXER_REPORT_RETENTION_DRY_RUN: 'false'});
|
||||
const config = await loadConfig();
|
||||
expect(config.report_retention).toEqual({days: 365, resolved_days: null, dry_run: false});
|
||||
});
|
||||
|
||||
test.each([
|
||||
['FLUXER_REPORT_RETENTION_DAYS', '0', 'FLUXER_REPORT_RETENTION_DAYS must be an integer between 1 and 36500'],
|
||||
['FLUXER_REPORT_RETENTION_DAYS', '36501', 'FLUXER_REPORT_RETENTION_DAYS must be an integer between 1 and 36500'],
|
||||
['FLUXER_REPORT_RETENTION_DAYS', '1.5', 'FLUXER_REPORT_RETENTION_DAYS must be an integer, got "1.5"'],
|
||||
[
|
||||
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS',
|
||||
'0',
|
||||
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS must be an integer between 1 and 36500',
|
||||
],
|
||||
[
|
||||
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS',
|
||||
'-30',
|
||||
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS must be an integer between 1 and 36500',
|
||||
],
|
||||
['FLUXER_REPORT_RETENTION_DRY_RUN', '1', 'FLUXER_REPORT_RETENTION_DRY_RUN must be true or false'],
|
||||
])('refuses %s=%j', async (name, value, message) => {
|
||||
stubMinimalEnv({[name]: value});
|
||||
await expect(loadConfig()).rejects.toThrow(message);
|
||||
});
|
||||
});
|
||||
|
||||
describe('FLUXER_PUBLIC_ORIGIN', () => {
|
||||
beforeEach(() => {
|
||||
resetConfig();
|
||||
|
||||
Reference in new issue
Block a user