feat: setup logs retention by max file size
This commit is contained in:
1 parent
70c8492f4f
commit
f914eae3c5
44 files changed
+2316
-161
No files matched your search
@@ -3,8 +3,11 @@ import { initializeLocale, setLocale } from '@/i18n'
|
||||
import type { WorkspaceSettings } from '@/composables/useSettings'
|
||||
import { recentWhenLabel } from '../activityTime'
|
||||
import {
|
||||
formatLogSize,
|
||||
helperCopy,
|
||||
isShorter,
|
||||
isSmaller,
|
||||
sizeHelperCopy,
|
||||
lastCleanupLine,
|
||||
nextCleanupLine,
|
||||
shorteningDescription,
|
||||
@@ -20,6 +23,8 @@ function settings(overrides: Partial<WorkspaceSettings> = {}): WorkspaceSettings
|
||||
return {
|
||||
version: 'v2.2.0-beta',
|
||||
activity_retention_days: 90,
|
||||
activity_retention_max_gb: 0,
|
||||
activity_log_size_bytes: 0,
|
||||
activity_last_cleanup_at: at(6, 3, 0),
|
||||
activity_last_cleanup_removed: 142,
|
||||
activity_next_cleanup_at: at(7, 3, 0),
|
||||
@@ -86,3 +91,43 @@ describe('retention lines', () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('retention size limit', () => {
|
||||
it('ranks 1 < 5 < 10 < 25 < 50 < No size limit', () => {
|
||||
expect(isSmaller(1, 5)).toBe(true)
|
||||
expect(isSmaller(5, 0)).toBe(true)
|
||||
expect(isSmaller(0, 50)).toBe(false)
|
||||
expect(isSmaller(5, 5)).toBe(false)
|
||||
expect(isSmaller(10, 50)).toBe(true)
|
||||
})
|
||||
|
||||
it.each([
|
||||
[0, 'Less than 0.1 GB'],
|
||||
[53687091, 'Less than 0.1 GB'],
|
||||
[107374183, '0.1 GB'],
|
||||
[1073741824, '1.0 GB'],
|
||||
[3435973837, '3.2 GB'],
|
||||
[5368709120, '5.0 GB'],
|
||||
])('formats %s bytes as %s on a 1024^3 base', (bytes, shown) => {
|
||||
expect(formatLogSize(bytes)).toBe(shown)
|
||||
})
|
||||
|
||||
it('words the helpers for each combination', () => {
|
||||
expect(helperCopy(90, 5)).toBe('Events older than this are removed.')
|
||||
expect(helperCopy(0, 5)).toBe('No age limit. Only the size limit applies.')
|
||||
expect(helperCopy(0, 0)).toBe('Nothing is removed automatically. The log grows over time.')
|
||||
expect(sizeHelperCopy(0, 99)).toBe('Optional. Logs can grow without a size cap.')
|
||||
expect(sizeHelperCopy(5, 3435973837)).toBe(
|
||||
'When logs pass 5 GB, the oldest events are removed. Currently 3.2 GB.',
|
||||
)
|
||||
})
|
||||
|
||||
it('words the helpers in French with Go and a decimal comma', () => {
|
||||
setLocale('fr')
|
||||
|
||||
expect(sizeHelperCopy(5, 3435973837)).toBe(
|
||||
'Au-delà de 5 Go, les événements les plus anciens sont supprimés. Actuellement 3,2 Go.',
|
||||
)
|
||||
expect(formatLogSize(0)).toBe('Moins de 0,1 Go')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user