Skip to content

Commit

Permalink
Fix tests and do not clear summary
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Apr 21, 2024
1 parent e449a9b commit 22bdadf
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 19 deletions.
24 changes: 16 additions & 8 deletions __tests__/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,12 +788,16 @@ func void Symbol11(var int Symbol12, var string Symbol13, var Symbol5 Symbol14)
;(parser as any)['version'] = 1
await parser['parseSpecial']('Ikarus')

expect(posixJoin).toHaveBeenCalledWith('.patch-validator-special', 'Ikarus-gameversions', 'Ikarus_G1.src')
expect(posixJoin).toHaveBeenCalledWith(expect.stringMatching(/\.patch-validator-special$/), 'Ikarus-gameversions', 'Ikarus_G1.src')
expect(tcDownloadToolMock).toHaveBeenCalledWith('https://github.com/Lehona/Ikarus/archive/refs/heads/gameversions.tar.gz')
expect(ioMkdirPMock).toHaveBeenCalledWith('.patch-validator-special')
expect(tcExtractTarMock).toHaveBeenCalledWith('/path/to/ikarus.tar.gz', '.patch-validator-special')
expect(ioMkdirPMock).toHaveBeenCalledWith(expect.stringMatching(/\.patch-validator-special$/))
expect(tcExtractTarMock).toHaveBeenCalledWith('/path/to/ikarus.tar.gz', expect.stringMatching(/\.patch-validator-special$/))
expect(ioRmRFMock).toHaveBeenCalledWith('/path/to/ikarus.tar.gz')
expect(parseSrc).toHaveBeenCalledWith('.patch-validator-special/Ikarus-gameversions/Ikarus_G1.src', false, true)
expect(parseSrc).toHaveBeenCalledWith(
expect.stringMatching(/\.patch-validator-special\/Ikarus-gameversions\/Ikarus_G1.src$/),
false,
true
)

expect(parser.symbolTable).toEqual([
{ name: 'DAM_INDEX_MAX', file: '', line: 0 },
Expand Down Expand Up @@ -831,12 +835,16 @@ func void Symbol11(var int Symbol12, var string Symbol13, var Symbol5 Symbol14)
;(parser as any)['version'] = 2
await parser['parseSpecial']('LeGo')

expect(posixJoin).toHaveBeenCalledWith('.patch-validator-special', 'LeGo-gameversions', 'Header_G2.src')
expect(posixJoin).toHaveBeenCalledWith(expect.stringMatching(/\.patch-validator-special$/), 'LeGo-gameversions', 'Header_G2.src')
expect(tcDownloadToolMock).toHaveBeenCalledWith('https://github.com/Lehona/LeGo/archive/refs/heads/gameversions.tar.gz')
expect(ioMkdirPMock).toHaveBeenCalledWith('.patch-validator-special')
expect(tcExtractTarMock).toHaveBeenCalledWith('/path/to/lego.tar.gz', '.patch-validator-special')
expect(ioMkdirPMock).toHaveBeenCalledWith(expect.stringMatching(/\.patch-validator-special$/))
expect(tcExtractTarMock).toHaveBeenCalledWith('/path/to/lego.tar.gz', expect.stringMatching(/\.patch-validator-special$/))
expect(ioRmRFMock).toHaveBeenCalledWith('/path/to/lego.tar.gz')
expect(parseSrc).toHaveBeenCalledWith('.patch-validator-special/LeGo-gameversions/Header_G2.src', false, true)
expect(parseSrc).toHaveBeenCalledWith(
expect.stringMatching(/\.patch-validator-special\/LeGo-gameversions\/Header_G2.src$/),
false,
true
)

expect(parser.symbolTable).toEqual([
{ name: 'LEGO_MERGEFLAGS', file: '', line: 0 },
Expand Down
12 changes: 6 additions & 6 deletions __tests__/write.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('annotations', () => {
title: '3 violations',
summary,
text:
'The patch validator checked 4 symbols.\n<br>\n<br>' +
'The patch validator checked 4 symbols.\n\n' +
'For more details, see [Ninja documentation](https://github.com/szapp/Ninja/wiki/Inject-Changes).',
annotations: expectedAnnotations,
}
Expand Down Expand Up @@ -172,7 +172,7 @@ describe('annotations', () => {
title: '1 violation',
summary,
text:
'The patch validator checked 1 symbol.\n<br>\n<br>' +
'The patch validator checked 1 symbol.\n\n' +
'For more details, see [Ninja documentation](https://github.com/szapp/Ninja/wiki/Inject-Changes).',
annotations: expectedAnnotations,
}
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('annotations', () => {
title: 'No violations',
summary,
text:
'The patch validator checked 1 symbol.\n<br>\n<br>' +
'The patch validator checked 1 symbol.\n\n' +
'For more details, see [Ninja documentation](https://github.com/szapp/Ninja/wiki/Inject-Changes).',
annotations: expectedAnnotations,
}
Expand Down Expand Up @@ -271,7 +271,7 @@ describe('summary', () => {
jest.spyOn(core.summary, 'addEOL').mockImplementation(() => core.summary)
jest.spyOn(core.summary, 'addList').mockImplementation(() => core.summary)
jest.spyOn(core.summary, 'stringify').mockImplementation(() => 'summary text')
jest.spyOn(core.summary, 'clear').mockImplementation()
jest.spyOn(core.summary, 'emptyBuffer').mockImplementation()
jest.spyOn(core.summary, 'write').mockImplementation()
})

Expand Down Expand Up @@ -321,7 +321,7 @@ describe('summary', () => {
expect(core.summary.addList).toHaveBeenCalledWith(['<code>PATCH_</code>', '<code>FOO_</code>', '<code>BAR_</code>'])
expect(core.summary.stringify).toHaveBeenCalled()
expect(core.summary.write).toHaveBeenCalledWith({ overwrite: false })
expect(core.summary.clear).toHaveBeenCalled()
expect(core.summary.emptyBuffer).toHaveBeenCalled()
expect(result).toBe('summary text')
})

Expand Down Expand Up @@ -363,7 +363,7 @@ describe('summary', () => {
expect(core.summary.addList).toHaveBeenCalledWith([])
expect(core.summary.stringify).toHaveBeenCalled()
expect(core.summary.write).not.toHaveBeenCalled()
expect(core.summary.clear).toHaveBeenCalled()
expect(core.summary.emptyBuffer).toHaveBeenCalled()
expect(result).toBe('summary text')
})
})
4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export async function annotations(
)
const numSymbols = parsers.reduce((acc, p) => acc + p.numSymbols, 0)
const text =
`The patch validator checked ${numSymbols} symbol${numSymbols !== 1 ? 's' : ''}.\n<br>\n<br>` +
`The patch validator checked ${numSymbols} symbol${numSymbols !== 1 ? 's' : ''}.\n\n` +
'For more details, see [Ninja documentation](https://github.com/szapp/Ninja/wiki/Inject-Changes).'

const octokit = github.getOctokit(core.getInput('token'))
Expand Down Expand Up @@ -182,7 +182,7 @@ export async function summary(

// Write summary to GitHub if enabled and clear buffer
if (write) await core.summary.write({ overwrite: false })
core.summary.clear()
core.summary.emptyBuffer()
return result
}

Expand Down

0 comments on commit 22bdadf

Please sign in to comment.