@@ -50,31 +50,21 @@ test.serial(
5050 "modified.js" : "ddd444" , // Changed OID
5151 "added.js" : "eee555" , // New file
5252 } ;
53- const getFileOidsStubForOverlay = sinon
54- . stub ( gitUtils , "getFileOidsUnderPath" )
55- . resolves ( currentOids ) ;
53+ sinon . stub ( gitUtils , "getFileOidsUnderPath" ) . resolves ( currentOids ) ;
5654
5755 // Write the overlay changes file, which uses the mocked overlay OIDs
5856 // and the base database OIDs file
5957 const diffRangeFilePath = path . join ( tempDir , "pr-diff-range.json" ) ;
60- const getTempDirStub = sinon
61- . stub ( actionsUtil , "getTemporaryDirectory" )
62- . returns ( tempDir ) ;
63- const getDiffRangesStub = sinon
58+ sinon . stub ( actionsUtil , "getTemporaryDirectory" ) . returns ( tempDir ) ;
59+ sinon
6460 . stub ( actionsUtil , "getDiffRangesJsonFilePath" )
6561 . returns ( diffRangeFilePath ) ;
66- const getGitRootStub = sinon
67- . stub ( gitUtils , "getGitRoot" )
68- . resolves ( sourceRoot ) ;
62+ sinon . stub ( gitUtils , "getGitRoot" ) . resolves ( sourceRoot ) ;
6963 const changesFilePath = await writeOverlayChangesFile (
7064 config ,
7165 sourceRoot ,
7266 logger ,
7367 ) ;
74- getFileOidsStubForOverlay . restore ( ) ;
75- getTempDirStub . restore ( ) ;
76- getDiffRangesStub . restore ( ) ;
77- getGitRootStub . restore ( ) ;
7868
7969 const fileContent = await fs . promises . readFile ( changesFilePath , "utf-8" ) ;
8070 const parsedContent = JSON . parse ( fileContent ) as { changes : string [ ] } ;
@@ -128,20 +118,14 @@ test.serial(
128118 "modified.js" : "ddd444" , // Changed OID
129119 "reverted.js" : "eee555" , // Same OID as base -- not detected by OID comparison
130120 } ;
131- const getFileOidsStubForOverlay = sinon
132- . stub ( gitUtils , "getFileOidsUnderPath" )
133- . resolves ( currentOids ) ;
121+ sinon . stub ( gitUtils , "getFileOidsUnderPath" ) . resolves ( currentOids ) ;
134122
135123 const diffRangeFilePath = path . join ( tempDir , "pr-diff-range.json" ) ;
136- const getTempDirStub = sinon
137- . stub ( actionsUtil , "getTemporaryDirectory" )
138- . returns ( tempDir ) ;
139- const getDiffRangesStub = sinon
124+ sinon . stub ( actionsUtil , "getTemporaryDirectory" ) . returns ( tempDir ) ;
125+ sinon
140126 . stub ( actionsUtil , "getDiffRangesJsonFilePath" )
141127 . returns ( diffRangeFilePath ) ;
142- const getGitRootStub = sinon
143- . stub ( gitUtils , "getGitRoot" )
144- . resolves ( sourceRoot ) ;
128+ sinon . stub ( gitUtils , "getGitRoot" ) . resolves ( sourceRoot ) ;
145129
146130 // Write a pr-diff-range.json file with diff ranges including
147131 // "reverted.js" (unchanged OIDs) and "modified.js" (already in OID changes)
@@ -159,10 +143,6 @@ test.serial(
159143 sourceRoot ,
160144 logger ,
161145 ) ;
162- getFileOidsStubForOverlay . restore ( ) ;
163- getTempDirStub . restore ( ) ;
164- getDiffRangesStub . restore ( ) ;
165- getGitRootStub . restore ( ) ;
166146
167147 const fileContent = await fs . promises . readFile ( changesFilePath , "utf-8" ) ;
168148 const parsedContent = JSON . parse ( fileContent ) as { changes : string [ ] } ;
@@ -208,31 +188,21 @@ test.serial(
208188 "unchanged.js" : "aaa111" ,
209189 "modified.js" : "ddd444" ,
210190 } ;
211- const getFileOidsStubForOverlay = sinon
212- . stub ( gitUtils , "getFileOidsUnderPath" )
213- . resolves ( currentOids ) ;
191+ sinon . stub ( gitUtils , "getFileOidsUnderPath" ) . resolves ( currentOids ) ;
214192
215193 const diffRangeFilePath = path . join ( tempDir , "pr-diff-range.json" ) ;
216- const getTempDirStub = sinon
217- . stub ( actionsUtil , "getTemporaryDirectory" )
218- . returns ( tempDir ) ;
219- const getDiffRangesStub = sinon
194+ sinon . stub ( actionsUtil , "getTemporaryDirectory" ) . returns ( tempDir ) ;
195+ sinon
220196 . stub ( actionsUtil , "getDiffRangesJsonFilePath" )
221197 . returns ( diffRangeFilePath ) ;
222- const getGitRootStub = sinon
223- . stub ( gitUtils , "getGitRoot" )
224- . resolves ( sourceRoot ) ;
198+ sinon . stub ( gitUtils , "getGitRoot" ) . resolves ( sourceRoot ) ;
225199
226200 // No pr-diff-range.json file exists - should work the same as before
227201 const changesFilePath = await writeOverlayChangesFile (
228202 config ,
229203 sourceRoot ,
230204 logger ,
231205 ) ;
232- getFileOidsStubForOverlay . restore ( ) ;
233- getTempDirStub . restore ( ) ;
234- getDiffRangesStub . restore ( ) ;
235- getGitRootStub . restore ( ) ;
236206
237207 const fileContent = await fs . promises . readFile ( changesFilePath , "utf-8" ) ;
238208 const parsedContent = JSON . parse ( fileContent ) as { changes : string [ ] } ;
@@ -281,21 +251,15 @@ test.serial(
281251 "app.js" : "aaa111" ,
282252 "lib/util.js" : "bbb222" ,
283253 } ;
284- const getFileOidsStubForOverlay = sinon
285- . stub ( gitUtils , "getFileOidsUnderPath" )
286- . resolves ( currentOids ) ;
254+ sinon . stub ( gitUtils , "getFileOidsUnderPath" ) . resolves ( currentOids ) ;
287255
288256 const diffRangeFilePath = path . join ( tempDir , "pr-diff-range.json" ) ;
289- const getTempDirStub = sinon
290- . stub ( actionsUtil , "getTemporaryDirectory" )
291- . returns ( tempDir ) ;
292- const getDiffRangesStub = sinon
257+ sinon . stub ( actionsUtil , "getTemporaryDirectory" ) . returns ( tempDir ) ;
258+ sinon
293259 . stub ( actionsUtil , "getDiffRangesJsonFilePath" )
294260 . returns ( diffRangeFilePath ) ;
295261 // getGitRoot returns the repo root (parent of sourceRoot)
296- const getGitRootStub = sinon
297- . stub ( gitUtils , "getGitRoot" )
298- . resolves ( repoRoot ) ;
262+ sinon . stub ( gitUtils , "getGitRoot" ) . resolves ( repoRoot ) ;
299263
300264 // Diff ranges use repo-root-relative paths (as returned by the GitHub compare API)
301265 await fs . promises . writeFile (
@@ -312,10 +276,6 @@ test.serial(
312276 sourceRoot ,
313277 logger ,
314278 ) ;
315- getFileOidsStubForOverlay . restore ( ) ;
316- getTempDirStub . restore ( ) ;
317- getDiffRangesStub . restore ( ) ;
318- getGitRootStub . restore ( ) ;
319279
320280 const fileContent = await fs . promises . readFile ( changesFilePath , "utf-8" ) ;
321281 const parsedContent = JSON . parse ( fileContent ) as { changes : string [ ] } ;
0 commit comments