set action inputs to required if they have defaults

This commit is contained in:
Michael Shick 2023-04-23 09:13:45 -04:00
parent 9c1e156588
commit 7ca8398d28
No known key found for this signature in database
GPG key ID: ADF5BC9704BB4A61
2 changed files with 6 additions and 18 deletions

View file

@ -29,7 +29,7 @@ type Inputs = {
const defaultInputs: Inputs = {
message: '',
'message-path': undefined,
'repo-token': '',
'repo-token': repoToken,
'message-id': 'add-pr-comment',
'allow-repeats': 'false',
}
@ -130,7 +130,6 @@ describe('add-pr-comment action', () => {
it('creates a comment with message text', async () => {
inputs.message = simpleMessage
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'true'
await expect(run()).resolves.not.toThrow()
@ -141,7 +140,6 @@ describe('add-pr-comment action', () => {
it('creates a comment with a message-path', async () => {
inputs.message = undefined
inputs['message-path'] = path.resolve(__dirname, './message.txt')
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'true'
await expect(run()).resolves.not.toThrow()
@ -152,18 +150,14 @@ describe('add-pr-comment action', () => {
it('fails when both message and message-path are defined', async () => {
inputs.message = 'foobar'
inputs['message-path'] = path.resolve(__dirname, './message.txt')
inputs['repo-token'] = repoToken
await expect(run()).resolves.not.toThrow()
expect(core.setFailed).toHaveBeenCalledWith('must specify only one, message or message-path')
})
it('creates a comment in an existing PR', async () => {
process.env['GITHUB_TOKEN'] = repoToken
inputs.message = simpleMessage
inputs['message-path'] = undefined
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'true'
github.context.payload = {
@ -204,7 +198,6 @@ describe('add-pr-comment action', () => {
it('creates a message when the message id does not exist', async () => {
inputs.message = simpleMessage
inputs['message-path'] = undefined
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'false'
inputs['message-id'] = 'custom-id'
@ -224,7 +217,6 @@ describe('add-pr-comment action', () => {
it('identifies an existing message by id and updates it', async () => {
inputs.message = simpleMessage
inputs['message-path'] = undefined
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'false'
const commentId = 123
@ -250,7 +242,6 @@ describe('add-pr-comment action', () => {
it('overrides the default message with a success message on success', async () => {
inputs.message = simpleMessage
inputs['message-path'] = undefined
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'false'
inputs['message-success'] = '666'
inputs.status = 'success'
@ -273,7 +264,6 @@ describe('add-pr-comment action', () => {
it('overrides the default message with a failure message on failure', async () => {
inputs.message = simpleMessage
inputs['message-path'] = undefined
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'false'
inputs['message-failure'] = '666'
inputs.status = 'failure'
@ -296,7 +286,6 @@ describe('add-pr-comment action', () => {
it('overrides the default message with a cancelled message on cancelled', async () => {
inputs.message = simpleMessage
inputs['message-path'] = undefined
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'false'
inputs['message-cancelled'] = '666'
inputs.status = 'cancelled'
@ -319,7 +308,6 @@ describe('add-pr-comment action', () => {
it('overrides the default message with a skipped message on skipped', async () => {
inputs.message = simpleMessage
inputs['message-path'] = undefined
inputs['repo-token'] = repoToken
inputs['allow-repeats'] = 'false'
inputs['message-skipped'] = '666'
inputs.status = 'skipped'