Skip to content

Commit

Permalink
test: happy path
Browse files Browse the repository at this point in the history
  • Loading branch information
willgeorgetaylor committed Dec 29, 2023
1 parent 0003dcf commit 5593b18
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ Thumbs.db
# Ignore built ts files
__tests__/runner/*

# Ignore test outputs
__tests__/outputs

# IDE files
.idea
.vscode
Expand Down
26 changes: 26 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import * as core from '@actions/core'
import * as main from '../src/main'
import { existsSync, unlinkSync } from 'fs'

// Mock the action's main function
const runMock = jest.spyOn(main, 'run')
Expand Down Expand Up @@ -38,6 +39,31 @@ describe('action', () => {
)
})

describe('with inputs', () => {
beforeEach(() => {
process.env['INPUT_include'] = './__tests__/fixtures/*.xml'
process.env['INPUT_output-path'] = './__tests__/outputs'
if (existsSync('./__tests__/outputs/Sample.xml')) {
unlinkSync('./__tests__/outputs/Sample.xml')
}
})
it('successfully outputs reduced reports', async () => {
await main.run()
expect(runMock).toHaveReturned()
expect(errorMock).not.toHaveBeenCalled()
expect(setFailedMock).not.toHaveBeenCalled()
expect(infoMock).toHaveBeenLastCalledWith(
'junit-reducer exited successfully'
)
// Expect that file exists there
expect(existsSync('./__tests__/outputs/Sample.xml')).toBe(true)
})
afterEach(() => {
delete process.env.INPUT_include
delete process.env.INPUT_output
})
})

it('successfully completes with a specific version', async () => {
getInputMock.mockImplementation((name: string): string => {
switch (name) {
Expand Down
2 changes: 1 addition & 1 deletion 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 output/Sample.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="Admin::Jobs::Applications::Actions::CreativeServicesIncBackgroundCheckTest" filepath="test/system/admin/jobs/applications/actions/creative_services_inc_background_check_test.rb" time="49.09959481199999" tests="5" failed="0" errors="0" skipped="0" assertions="17">
<testcase name="test_should_not_see_Creative_Services_Inc_integration_when_removed" classname="Admin::Jobs::Applications::Actions::CreativeServicesIncBackgroundCheckTest" file="test/system/admin/jobs/applications/actions/creative_services_inc_background_check_test.rb" lineno="53" assertions="1" time="4.922785552499988"></testcase>
<testcase name="test_should_show_each_of_the_different_values_depending_on_which_billing_option_you_select" classname="Admin::Jobs::Applications::Actions::CreativeServicesIncBackgroundCheckTest" file="test/system/admin/jobs/applications/actions/creative_services_inc_background_check_test.rb" lineno="90" assertions="0" time="12.873165432000008"></testcase>
<testcase name="test_should_not_be_able_to_view_a_background_check_without_background_check_viewer_role" classname="Admin::Jobs::Applications::Actions::CreativeServicesIncBackgroundCheckTest" file="test/system/admin/jobs/applications/actions/creative_services_inc_background_check_test.rb" lineno="176" assertions="2" time="4.697016684999994"></testcase>
<testcase name="test_should_not_see_Creative_Services_Inc_integration_when_removed" classname="Admin::Jobs::Applications::Actions::CreativeServicesIncBackgroundCheckTest" file="test/system/admin/jobs/applications/actions/creative_services_inc_background_check_test.rb" lineno="53" assertions="1" time="4.922785552499988"></testcase>
</testsuite>
</testsuites>
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export async function run(): Promise<void> {

const inputs = enumerateInputs()
const args: string[] = Object.entries(inputs).map(
([key, value]) => `--${key} = ${value}`
([key, value]) => `--${key}=${value}`
)

core.startGroup(`Running junit - reducer with arguments: `)
Expand Down

0 comments on commit 5593b18

Please sign in to comment.