mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-14 20:16:48 -07:00
style: fix prettier formatting and eslint errors on test files
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,5 +1,4 @@
|
|||||||
import { OrchestratorFolders } from './orchestrator-folders';
|
import { OrchestratorFolders } from './orchestrator-folders';
|
||||||
import path from 'node:path';
|
|
||||||
|
|
||||||
// Mock Orchestrator
|
// Mock Orchestrator
|
||||||
jest.mock('../orchestrator', () => ({
|
jest.mock('../orchestrator', () => ({
|
||||||
@@ -61,9 +60,7 @@ describe('OrchestratorFolders', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles mixed slashes', () => {
|
it('handles mixed slashes', () => {
|
||||||
expect(OrchestratorFolders.ToLinuxFolder('some/path\\mixed/slashes\\here')).toBe(
|
expect(OrchestratorFolders.ToLinuxFolder('some/path\\mixed/slashes\\here')).toBe('some/path/mixed/slashes/here');
|
||||||
'some/path/mixed/slashes/here',
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles empty string', () => {
|
it('handles empty string', () => {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { FollowLogStreamService } from './follow-log-stream-service';
|
import { FollowLogStreamService } from './follow-log-stream-service';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import GitHub from '../../../github';
|
||||||
|
|
||||||
// Mock dependencies
|
// Mock dependencies
|
||||||
jest.mock('../../../github', () => ({
|
jest.mock('../../../github', () => ({
|
||||||
@@ -39,9 +41,6 @@ jest.mock('./orchestrator-logger', () => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
import * as core from '@actions/core';
|
|
||||||
import GitHub from '../../../github';
|
|
||||||
|
|
||||||
describe('FollowLogStreamService', () => {
|
describe('FollowLogStreamService', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
@@ -59,23 +58,13 @@ describe('FollowLogStreamService', () => {
|
|||||||
|
|
||||||
describe('handleIteration', () => {
|
describe('handleIteration', () => {
|
||||||
it('detects end of transmission marker', () => {
|
it('detects end of transmission marker', () => {
|
||||||
const result = FollowLogStreamService.handleIteration(
|
const result = FollowLogStreamService.handleIteration('---test-log-id-123', true, false, '');
|
||||||
'---test-log-id-123',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(FollowLogStreamService.DidReceiveEndOfTransmission).toBe(true);
|
expect(FollowLogStreamService.DidReceiveEndOfTransmission).toBe(true);
|
||||||
expect(result.shouldReadLogs).toBe(false);
|
expect(result.shouldReadLogs).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not trigger end of transmission for non-matching log ID', () => {
|
it('does not trigger end of transmission for non-matching log ID', () => {
|
||||||
const result = FollowLogStreamService.handleIteration(
|
const result = FollowLogStreamService.handleIteration('---different-log-id', true, false, '');
|
||||||
'---different-log-id',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(FollowLogStreamService.DidReceiveEndOfTransmission).toBe(false);
|
expect(FollowLogStreamService.DidReceiveEndOfTransmission).toBe(false);
|
||||||
expect(result.shouldReadLogs).toBe(true);
|
expect(result.shouldReadLogs).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -87,32 +76,19 @@ describe('FollowLogStreamService', () => {
|
|||||||
false,
|
false,
|
||||||
'',
|
'',
|
||||||
);
|
);
|
||||||
expect(GitHub.updateGitHubCheck).toHaveBeenCalledWith(
|
expect(GitHub.updateGitHubCheck).toHaveBeenCalledWith('Library was not found, importing new Library', '');
|
||||||
'Library was not found, importing new Library',
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(core.warning).toHaveBeenCalledWith('LIBRARY NOT FOUND!');
|
expect(core.warning).toHaveBeenCalledWith('LIBRARY NOT FOUND!');
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('library-found', 'false');
|
expect(core.setOutput).toHaveBeenCalledWith('library-found', 'false');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('detects Build succeeded message', () => {
|
it('detects Build succeeded message', () => {
|
||||||
FollowLogStreamService.handleIteration(
|
FollowLogStreamService.handleIteration('Build succeeded', true, false, '');
|
||||||
'Build succeeded',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(GitHub.updateGitHubCheck).toHaveBeenCalledWith('Build succeeded', 'Build succeeded');
|
expect(GitHub.updateGitHubCheck).toHaveBeenCalledWith('Build succeeded', 'Build succeeded');
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('build-result', 'success');
|
expect(core.setOutput).toHaveBeenCalledWith('build-result', 'success');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('detects Build fail message', () => {
|
it('detects Build fail message', () => {
|
||||||
FollowLogStreamService.handleIteration(
|
FollowLogStreamService.handleIteration('Build fail', true, false, '');
|
||||||
'Build fail',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(GitHub.updateGitHubCheck).toHaveBeenCalled();
|
expect(GitHub.updateGitHubCheck).toHaveBeenCalled();
|
||||||
expect(core.setOutput).toHaveBeenCalledWith('build-result', 'failed');
|
expect(core.setOutput).toHaveBeenCalledWith('build-result', 'failed');
|
||||||
expect(core.setFailed).toHaveBeenCalledWith('unity build failed');
|
expect(core.setFailed).toHaveBeenCalledWith('unity build failed');
|
||||||
@@ -120,95 +96,50 @@ describe('FollowLogStreamService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('accumulates error messages with "error " pattern', () => {
|
it('accumulates error messages with "error " pattern', () => {
|
||||||
FollowLogStreamService.handleIteration(
|
FollowLogStreamService.handleIteration('error CS0001: Something went wrong', true, false, '');
|
||||||
'error CS0001: Something went wrong',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(FollowLogStreamService.errors).toContain('error CS0001: Something went wrong');
|
expect(FollowLogStreamService.errors).toContain('error CS0001: Something went wrong');
|
||||||
expect(core.error).toHaveBeenCalled();
|
expect(core.error).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accumulates error messages with "error: " pattern', () => {
|
it('accumulates error messages with "error: " pattern', () => {
|
||||||
FollowLogStreamService.handleIteration(
|
FollowLogStreamService.handleIteration('Fatal Error: Out of memory', true, false, '');
|
||||||
'Fatal Error: Out of memory',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(FollowLogStreamService.errors).toContain('Fatal Error: Out of memory');
|
expect(FollowLogStreamService.errors).toContain('Fatal Error: Out of memory');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accumulates "command failed: " messages', () => {
|
it('accumulates "command failed: " messages', () => {
|
||||||
FollowLogStreamService.handleIteration(
|
FollowLogStreamService.handleIteration('command failed: git pull', true, false, '');
|
||||||
'command failed: git pull',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(FollowLogStreamService.errors).toContain('command failed: git pull');
|
expect(FollowLogStreamService.errors).toContain('command failed: git pull');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accumulates "invalid " messages', () => {
|
it('accumulates "invalid " messages', () => {
|
||||||
FollowLogStreamService.handleIteration(
|
FollowLogStreamService.handleIteration('invalid configuration value', true, false, '');
|
||||||
'invalid configuration value',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(FollowLogStreamService.errors).toContain('invalid configuration value');
|
expect(FollowLogStreamService.errors).toContain('invalid configuration value');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accumulates "cannot be found" messages', () => {
|
it('accumulates "cannot be found" messages', () => {
|
||||||
FollowLogStreamService.handleIteration(
|
FollowLogStreamService.handleIteration('Assembly cannot be found', true, false, '');
|
||||||
'Assembly cannot be found',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(FollowLogStreamService.errors).toContain('Assembly cannot be found');
|
expect(FollowLogStreamService.errors).toContain('Assembly cannot be found');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('appends message to output', () => {
|
it('appends message to output', () => {
|
||||||
const result = FollowLogStreamService.handleIteration(
|
const result = FollowLogStreamService.handleIteration('Some normal log line', true, false, 'previous output\n');
|
||||||
'Some normal log line',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'previous output\n',
|
|
||||||
);
|
|
||||||
expect(result.output).toContain('Some normal log line');
|
expect(result.output).toContain('Some normal log line');
|
||||||
expect(result.output).toContain('previous output');
|
expect(result.output).toContain('previous output');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('preserves shouldCleanup value', () => {
|
it('preserves shouldCleanup value', () => {
|
||||||
const result = FollowLogStreamService.handleIteration(
|
const result = FollowLogStreamService.handleIteration('normal message', true, true, '');
|
||||||
'normal message',
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(result.shouldCleanup).toBe(true);
|
expect(result.shouldCleanup).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not change shouldReadLogs for normal messages', () => {
|
it('does not change shouldReadLogs for normal messages', () => {
|
||||||
const result = FollowLogStreamService.handleIteration(
|
const result = FollowLogStreamService.handleIteration('Just a regular build log', true, false, '');
|
||||||
'Just a regular build log',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
expect(result.shouldReadLogs).toBe(true);
|
expect(result.shouldReadLogs).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('includes accumulated errors in Build fail GitHub check message', () => {
|
it('includes accumulated errors in Build fail GitHub check message', () => {
|
||||||
FollowLogStreamService.errors = '\nprevious error';
|
FollowLogStreamService.errors = '\nprevious error';
|
||||||
FollowLogStreamService.handleIteration(
|
FollowLogStreamService.handleIteration('Build fail', true, false, '');
|
||||||
'Build fail',
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
);
|
|
||||||
const updateCall = (GitHub.updateGitHubCheck as jest.Mock).mock.calls[0];
|
const updateCall = (GitHub.updateGitHubCheck as jest.Mock).mock.calls[0];
|
||||||
expect(updateCall[0]).toContain('previous error');
|
expect(updateCall[0]).toContain('previous error');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user