feat: logrotate test

This commit is contained in:
Eli Bosley
2025-02-03 15:13:14 -05:00
parent 7f997663f9
commit 5b0971ea8d
5 changed files with 36 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ import AuthRequestModification from '@app/unraid-api/unraid-file-modifier/modifi
import DefaultPageLayoutModification from '@app/unraid-api/unraid-file-modifier/modifications/default-page-layout.modification';
import NotificationsPageModification from '@app/unraid-api/unraid-file-modifier/modifications/notifications-page.modification';
import SSOFileModification from '@app/unraid-api/unraid-file-modifier/modifications/sso.modification';
import { LogRotateModification } from '@app/unraid-api/unraid-file-modifier/modifications/log-rotate.modification';
interface ModificationTestCase {
ModificationClass: new (...args: ConstructorParameters<typeof FileModification>) => FileModification;
@@ -41,6 +42,11 @@ const testCases: ModificationTestCase[] = [
fileUrl: 'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/auth-request.php',
fileName: 'auth-request.php',
},
{
ModificationClass: LogRotateModification,
fileUrl: 'logrotate.conf',
fileName: 'logrotate.conf',
},
];
async function testModification(testCase: ModificationTestCase) {
@@ -66,8 +72,6 @@ async function testModification(testCase: ModificationTestCase) {
originalContent = await readFile(path, 'utf-8');
}
expect(originalContent.length).toBeGreaterThan(0);
const logger = new Logger();
const patcher = await new testCase.ModificationClass(logger);
// @ts-expect-error - Ignore for testing purposes

View File

@@ -0,0 +1,12 @@
/var/log/unraid-api/*.log {
rotate 1
missingok
size 1M
su root root
compress
delaycompress
copytruncate
create 0640 root root
}

View File

@@ -0,0 +1,18 @@
Index: /app/src/unraid-api/unraid-file-modifier/modifications/__fixtures__/downloaded/logrotate.conf
===================================================================
--- /app/src/unraid-api/unraid-file-modifier/modifications/__fixtures__/downloaded/logrotate.conf
+++ /app/src/unraid-api/unraid-file-modifier/modifications/__fixtures__/downloaded/logrotate.conf
@@ -0,0 +1,12 @@
+
+/var/log/unraid-api/*.log {
+ rotate 1
+ missingok
+ size 1M
+ su root root
+ compress
+ delaycompress
+ copytruncate
+ create 0640 root root
+}
+
\ No newline at end of file

View File

@@ -1,4 +1,3 @@
import type { Logger } from '@nestjs/common';
import { readFile } from 'node:fs/promises';
import { createPatch } from 'diff';