mirror of
https://github.com/unraid/api.git
synced 2025-12-31 21:49:57 -06:00
feat: logrotate test
This commit is contained in:
@@ -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 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 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 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 {
|
interface ModificationTestCase {
|
||||||
ModificationClass: new (...args: ConstructorParameters<typeof FileModification>) => FileModification;
|
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',
|
fileUrl: 'https://github.com/unraid/webgui/raw/refs/heads/master/emhttp/auth-request.php',
|
||||||
fileName: 'auth-request.php',
|
fileName: 'auth-request.php',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ModificationClass: LogRotateModification,
|
||||||
|
fileUrl: 'logrotate.conf',
|
||||||
|
fileName: 'logrotate.conf',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
async function testModification(testCase: ModificationTestCase) {
|
async function testModification(testCase: ModificationTestCase) {
|
||||||
@@ -66,8 +72,6 @@ async function testModification(testCase: ModificationTestCase) {
|
|||||||
originalContent = await readFile(path, 'utf-8');
|
originalContent = await readFile(path, 'utf-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(originalContent.length).toBeGreaterThan(0);
|
|
||||||
|
|
||||||
const logger = new Logger();
|
const logger = new Logger();
|
||||||
const patcher = await new testCase.ModificationClass(logger);
|
const patcher = await new testCase.ModificationClass(logger);
|
||||||
// @ts-expect-error - Ignore for testing purposes
|
// @ts-expect-error - Ignore for testing purposes
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
/var/log/unraid-api/*.log {
|
||||||
|
rotate 1
|
||||||
|
missingok
|
||||||
|
size 1M
|
||||||
|
su root root
|
||||||
|
compress
|
||||||
|
delaycompress
|
||||||
|
copytruncate
|
||||||
|
create 0640 root root
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
import type { Logger } from '@nestjs/common';
|
|
||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } from 'node:fs/promises';
|
||||||
|
|
||||||
import { createPatch } from 'diff';
|
import { createPatch } from 'diff';
|
||||||
|
|||||||
Reference in New Issue
Block a user