Skip to content

Commit e5d967e

Browse files
committed
test: fix existing tests' string formatting
1 parent 64c0c7e commit e5d967e

File tree

1 file changed

+30
-37
lines changed

1 file changed

+30
-37
lines changed

test/testParsePush.test.js

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,12 @@ describe('parsePackFile', () => {
178178
const ref = 'refs/heads/main';
179179
const packetLine = `${oldCommit} ${newCommit} ${ref}\0capabilities\n`;
180180

181-
const commitContent = `tree 1234567890abcdef1234567890abcdef12345678
182-
parent abcdef1234567890abcdef1234567890abcdef12
183-
author Test Author <[email protected]> 1234567890 +0000
184-
committer Test Committer <[email protected]> 1234567890 +0000
185-
186-
feat: Add new feature
187-
188-
This is the commit body.`;
181+
const commitContent = "tree 1234567890abcdef1234567890abcdef12345678\n" +
182+
"parent abcdef1234567890abcdef1234567890abcdef12\n" +
183+
"author Test Author <[email protected]> 1234567890 +0000\n" +
184+
"committer Test Committer <[email protected]> 1234567890 +0000\n\n" +
185+
"feat: Add new feature\n\n" +
186+
"This is the commit body.";
189187
const commitContentBuffer = Buffer.from(commitContent, 'utf8');
190188

191189
zlibInflateStub.returns(commitContentBuffer);
@@ -237,11 +235,10 @@ describe('parsePackFile', () => {
237235
const packetLine = `${oldCommit} ${newCommit} ${ref}\0capabilities\n`;
238236

239237
// Commit content without a parent line
240-
const commitContent = `tree 1234567890abcdef1234567890abcdef12345678
241-
author Test Author <[email protected]> 1234567890 +0000
242-
committer Test Committer <[email protected]> 1234567890 +0100
243-
244-
feat: Initial commit`;
238+
const commitContent = "tree 1234567890abcdef1234567890abcdef12345678\n" +
239+
"author Test Author <[email protected]> 1234567890 +0000\n" +
240+
"committer Test Committer <[email protected]> 1234567890 +0100\n\n" +
241+
"feat: Initial commit";
245242
const parentFromCommit = '0'.repeat(40); // Expected parent hash
246243

247244
const commitContentBuffer = Buffer.from(commitContent, 'utf8');
@@ -277,13 +274,12 @@ describe('parsePackFile', () => {
277274

278275
const parent1 = 'b1'.repeat(20);
279276
const parent2 = 'b2'.repeat(20);
280-
const commitContent = `tree 1234567890abcdef1234567890abcdef12345678
281-
parent ${parent1}
282-
parent ${parent2}
283-
author Test Author <[email protected]> 1234567890 +0000
284-
committer Test Committer <[email protected]> 1234567890 +0100
285-
286-
Merge branch 'feature'`;
277+
const commitContent = "tree 1234567890abcdef1234567890abcdef12345678\n" +
278+
`parent ${parent1}\n` +
279+
`parent ${parent2}\n` +
280+
"author Test Author <[email protected]> 1234567890 +0000\n" +
281+
"committer Test Committer <[email protected]> 1234567890 +0100\n\n" +
282+
"Merge branch 'feature'";
287283

288284
const commitContentBuffer = Buffer.from(commitContent, 'utf8');
289285
zlibInflateStub.returns(commitContentBuffer);
@@ -315,11 +311,10 @@ describe('parsePackFile', () => {
315311
const packetLine = `${oldCommit} ${newCommit} ${ref}\0capabilities\n`;
316312

317313
// Malformed commit content - missing tree line
318-
const commitContent = `parent abcdef1234567890abcdef1234567890abcdef12
319-
author Test Author <[email protected]> 1678886400 +0000
320-
committer Test Committer <[email protected]> 1678886460 +0100
321-
322-
feat: Missing tree`;
314+
const commitContent = "parent abcdef1234567890abcdef1234567890abcdef12\n" +
315+
"author Test Author <[email protected]> 1678886400 +0000\n" +
316+
"committer Test Committer <[email protected]> 1678886460 +0100\n\n" +
317+
"feat: Missing tree";
323318
const commitContentBuffer = Buffer.from(commitContent, 'utf8');
324319
zlibInflateStub.returns(commitContentBuffer);
325320

@@ -367,12 +362,11 @@ describe('parsePackFile', () => {
367362
'some other data containing PACK keyword', // Include "PACK" within a packet line's content
368363
];
369364

370-
const commitContent = `tree 1234567890abcdef1234567890abcdef12345678
371-
parent ${oldCommit}
372-
author Test Author <[email protected]> 1234567890 +0000
373-
committer Test Committer <[email protected]> 1234567890 +0000
374-
375-
Test commit message with PACK inside`;
365+
const commitContent = "tree 1234567890abcdef1234567890abcdef12345678\n" +
366+
`parent ${oldCommit}\n` +
367+
"author Test Author <[email protected]> 1234567890 +0000\n" +
368+
"committer Test Committer <[email protected]> 1234567890 +0000\n\n" +
369+
"Test commit message with PACK inside";
376370
const samplePackBuffer = createSamplePackBuffer(1, commitContent, 1);
377371

378372
zlibInflateStub.returns(Buffer.from(commitContent, 'utf8'));
@@ -407,12 +401,11 @@ describe('parsePackFile', () => {
407401
const ref = 'refs/heads/master';
408402
const packetLines = [`${oldCommit} ${newCommit} ${ref}\0`];
409403

410-
const commitContent = `tree 1234567890abcdef1234567890abcdef12345678
411-
parent ${oldCommit}
412-
author Test Author <[email protected]> 1234567890 +0000
413-
committer Test Committer <[email protected]> 1234567890 +0000
414-
415-
Commit A`;
404+
const commitContent = "tree 1234567890abcdef1234567890abcdef12345678\n" +
405+
`parent ${oldCommit}\n` +
406+
"author Test Author <[email protected]> 1234567890 +0000\n" +
407+
"committer Test Committer <[email protected]> 1234567890 +0000\n\n" +
408+
"Commit A";
416409
const samplePackBuffer = createSamplePackBuffer(1, commitContent, 1);
417410
zlibInflateStub.returns(Buffer.from(commitContent, 'utf8'));
418411

0 commit comments

Comments
 (0)