11import { FollowLogStreamService } from './follow-log-stream-service' ;
2+ import * as core from '@actions/core' ;
3+ import GitHub from '../../../github' ;
24
35// Mock dependencies
46jest . mock ( '../../../github' , ( ) => ( {
@@ -39,9 +41,6 @@ jest.mock('./orchestrator-logger', () => ({
3941 } ,
4042} ) ) ;
4143
42- import * as core from '@actions/core' ;
43- import GitHub from '../../../github' ;
44-
4544describe ( 'FollowLogStreamService' , ( ) => {
4645 beforeEach ( ( ) => {
4746 jest . clearAllMocks ( ) ;
@@ -59,23 +58,13 @@ describe('FollowLogStreamService', () => {
5958
6059 describe ( 'handleIteration' , ( ) => {
6160 it ( 'detects end of transmission marker' , ( ) => {
62- const result = FollowLogStreamService . handleIteration (
63- '---test-log-id-123' ,
64- true ,
65- false ,
66- '' ,
67- ) ;
61+ const result = FollowLogStreamService . handleIteration ( '---test-log-id-123' , true , false , '' ) ;
6862 expect ( FollowLogStreamService . DidReceiveEndOfTransmission ) . toBe ( true ) ;
6963 expect ( result . shouldReadLogs ) . toBe ( false ) ;
7064 } ) ;
7165
7266 it ( 'does not trigger end of transmission for non-matching log ID' , ( ) => {
73- const result = FollowLogStreamService . handleIteration (
74- '---different-log-id' ,
75- true ,
76- false ,
77- '' ,
78- ) ;
67+ const result = FollowLogStreamService . handleIteration ( '---different-log-id' , true , false , '' ) ;
7968 expect ( FollowLogStreamService . DidReceiveEndOfTransmission ) . toBe ( false ) ;
8069 expect ( result . shouldReadLogs ) . toBe ( true ) ;
8170 } ) ;
@@ -87,128 +76,70 @@ describe('FollowLogStreamService', () => {
8776 false ,
8877 '' ,
8978 ) ;
90- expect ( GitHub . updateGitHubCheck ) . toHaveBeenCalledWith (
91- 'Library was not found, importing new Library' ,
92- '' ,
93- ) ;
79+ expect ( GitHub . updateGitHubCheck ) . toHaveBeenCalledWith ( 'Library was not found, importing new Library' , '' ) ;
9480 expect ( core . warning ) . toHaveBeenCalledWith ( 'LIBRARY NOT FOUND!' ) ;
9581 expect ( core . setOutput ) . toHaveBeenCalledWith ( 'library-found' , 'false' ) ;
9682 } ) ;
9783
9884 it ( 'detects Build succeeded message' , ( ) => {
99- FollowLogStreamService . handleIteration (
100- 'Build succeeded' ,
101- true ,
102- false ,
103- '' ,
104- ) ;
85+ FollowLogStreamService . handleIteration ( 'Build succeeded' , true , false , '' ) ;
10586 expect ( GitHub . updateGitHubCheck ) . toHaveBeenCalledWith ( 'Build succeeded' , 'Build succeeded' ) ;
10687 expect ( core . setOutput ) . toHaveBeenCalledWith ( 'build-result' , 'success' ) ;
10788 } ) ;
10889
10990 it ( 'detects Build fail message' , ( ) => {
110- FollowLogStreamService . handleIteration (
111- 'Build fail' ,
112- true ,
113- false ,
114- '' ,
115- ) ;
91+ FollowLogStreamService . handleIteration ( 'Build fail' , true , false , '' ) ;
11692 expect ( GitHub . updateGitHubCheck ) . toHaveBeenCalled ( ) ;
11793 expect ( core . setOutput ) . toHaveBeenCalledWith ( 'build-result' , 'failed' ) ;
11894 expect ( core . setFailed ) . toHaveBeenCalledWith ( 'unity build failed' ) ;
11995 expect ( core . error ) . toHaveBeenCalledWith ( 'BUILD FAILED!' ) ;
12096 } ) ;
12197
12298 it ( 'accumulates error messages with "error " pattern' , ( ) => {
123- FollowLogStreamService . handleIteration (
124- 'error CS0001: Something went wrong' ,
125- true ,
126- false ,
127- '' ,
128- ) ;
99+ FollowLogStreamService . handleIteration ( 'error CS0001: Something went wrong' , true , false , '' ) ;
129100 expect ( FollowLogStreamService . errors ) . toContain ( 'error CS0001: Something went wrong' ) ;
130101 expect ( core . error ) . toHaveBeenCalled ( ) ;
131102 } ) ;
132103
133104 it ( 'accumulates error messages with "error: " pattern' , ( ) => {
134- FollowLogStreamService . handleIteration (
135- 'Fatal Error: Out of memory' ,
136- true ,
137- false ,
138- '' ,
139- ) ;
105+ FollowLogStreamService . handleIteration ( 'Fatal Error: Out of memory' , true , false , '' ) ;
140106 expect ( FollowLogStreamService . errors ) . toContain ( 'Fatal Error: Out of memory' ) ;
141107 } ) ;
142108
143109 it ( 'accumulates "command failed: " messages' , ( ) => {
144- FollowLogStreamService . handleIteration (
145- 'command failed: git pull' ,
146- true ,
147- false ,
148- '' ,
149- ) ;
110+ FollowLogStreamService . handleIteration ( 'command failed: git pull' , true , false , '' ) ;
150111 expect ( FollowLogStreamService . errors ) . toContain ( 'command failed: git pull' ) ;
151112 } ) ;
152113
153114 it ( 'accumulates "invalid " messages' , ( ) => {
154- FollowLogStreamService . handleIteration (
155- 'invalid configuration value' ,
156- true ,
157- false ,
158- '' ,
159- ) ;
115+ FollowLogStreamService . handleIteration ( 'invalid configuration value' , true , false , '' ) ;
160116 expect ( FollowLogStreamService . errors ) . toContain ( 'invalid configuration value' ) ;
161117 } ) ;
162118
163119 it ( 'accumulates "cannot be found" messages' , ( ) => {
164- FollowLogStreamService . handleIteration (
165- 'Assembly cannot be found' ,
166- true ,
167- false ,
168- '' ,
169- ) ;
120+ FollowLogStreamService . handleIteration ( 'Assembly cannot be found' , true , false , '' ) ;
170121 expect ( FollowLogStreamService . errors ) . toContain ( 'Assembly cannot be found' ) ;
171122 } ) ;
172123
173124 it ( 'appends message to output' , ( ) => {
174- const result = FollowLogStreamService . handleIteration (
175- 'Some normal log line' ,
176- true ,
177- false ,
178- 'previous output\n' ,
179- ) ;
125+ const result = FollowLogStreamService . handleIteration ( 'Some normal log line' , true , false , 'previous output\n' ) ;
180126 expect ( result . output ) . toContain ( 'Some normal log line' ) ;
181127 expect ( result . output ) . toContain ( 'previous output' ) ;
182128 } ) ;
183129
184130 it ( 'preserves shouldCleanup value' , ( ) => {
185- const result = FollowLogStreamService . handleIteration (
186- 'normal message' ,
187- true ,
188- true ,
189- '' ,
190- ) ;
131+ const result = FollowLogStreamService . handleIteration ( 'normal message' , true , true , '' ) ;
191132 expect ( result . shouldCleanup ) . toBe ( true ) ;
192133 } ) ;
193134
194135 it ( 'does not change shouldReadLogs for normal messages' , ( ) => {
195- const result = FollowLogStreamService . handleIteration (
196- 'Just a regular build log' ,
197- true ,
198- false ,
199- '' ,
200- ) ;
136+ const result = FollowLogStreamService . handleIteration ( 'Just a regular build log' , true , false , '' ) ;
201137 expect ( result . shouldReadLogs ) . toBe ( true ) ;
202138 } ) ;
203139
204140 it ( 'includes accumulated errors in Build fail GitHub check message' , ( ) => {
205141 FollowLogStreamService . errors = '\nprevious error' ;
206- FollowLogStreamService . handleIteration (
207- 'Build fail' ,
208- true ,
209- false ,
210- '' ,
211- ) ;
142+ FollowLogStreamService . handleIteration ( 'Build fail' , true , false , '' ) ;
212143 const updateCall = ( GitHub . updateGitHubCheck as jest . Mock ) . mock . calls [ 0 ] ;
213144 expect ( updateCall [ 0 ] ) . toContain ( 'previous error' ) ;
214145 } ) ;
0 commit comments