From 3d8f52592080f79140af2045f11b5e1cd717b289 Mon Sep 17 00:00:00 2001 From: Jules Camille Date: Mon, 24 Oct 2022 11:28:18 +0200 Subject: [PATCH] Use method core.exportVariable instead of core.set-output fix https://github.com/slackapi/slack-github-action/issues/141 --- src/slack-send.js | 6 +++--- test/slack-send-test.js | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/slack-send.js b/src/slack-send.js index e204c049..5f14ad46 100644 --- a/src/slack-send.js +++ b/src/slack-send.js @@ -141,14 +141,14 @@ module.exports = async function slackSend(core) { } if (webResponse && webResponse.ok) { - core.setOutput('ts', webResponse.ts); + core.exportVariable('ts', webResponse.ts); // return the thread_ts if it exists, if not return the ts const thread_ts = webResponse.thread_ts ? webResponse.thread_ts : webResponse.ts; - core.setOutput('thread_ts', thread_ts); + core.exportVariable('thread_ts', thread_ts); } const time = (new Date()).toTimeString(); - core.setOutput('time', time); + core.exportVariable('time', time); } catch (error) { core.setFailed(error); } diff --git a/test/slack-send-test.js b/test/slack-send-test.js index 06d6347a..f316f723 100644 --- a/test/slack-send-test.js +++ b/test/slack-send-test.js @@ -58,11 +58,11 @@ describe('slack-send', () => { fakeCore.getInput.withArgs('slack-message').returns('who let the dogs out?'); fakeCore.getInput.withArgs('channel-id').returns('C123456'); await slackSend(fakeCore); - assert.equal(fakeCore.setOutput.firstCall.firstArg, 'ts', 'Output name set to ts'); - assert.equal(fakeCore.setOutput.secondCall.firstArg, 'thread_ts', 'Output name set to thread_ts'); - assert(fakeCore.setOutput.secondCall.lastArg.length > 0, 'Time output a non-zero-length string'); - assert.equal(fakeCore.setOutput.lastCall.firstArg, 'time', 'Output name set to time'); - assert(fakeCore.setOutput.lastCall.lastArg.length > 0, 'Time output a non-zero-length string'); + assert.equal(fakeCore.exportVariable.firstCall.firstArg, 'ts', 'Output name set to ts'); + assert.equal(fakeCore.exportVariable.secondCall.firstArg, 'thread_ts', 'Output name set to thread_ts'); + assert(fakeCore.exportVariable.secondCall.lastArg.length > 0, 'Time output a non-zero-length string'); + assert.equal(fakeCore.exportVariable.lastCall.firstArg, 'time', 'Output name set to time'); + assert(fakeCore.exportVariable.lastCall.lastArg.length > 0, 'Time output a non-zero-length string'); const chatArgs = ChatStub.postMessage.lastCall.firstArg; assert.equal(chatArgs.channel, 'C123456', 'Correct channel provided to postMessage'); assert.equal(chatArgs.text, 'who let the dogs out?', 'Correct message provided to postMessage'); @@ -73,11 +73,11 @@ describe('slack-send', () => { fakeCore.getInput.withArgs('channel-id').returns('C123456'); fakeCore.getInput.withArgs('update-ts').returns('123456'); await slackSend(fakeCore); - assert.equal(fakeCore.setOutput.firstCall.firstArg, 'ts', 'Output name set to ts'); - assert.equal(fakeCore.setOutput.secondCall.firstArg, 'thread_ts', 'Output name set to thread_ts'); - assert(fakeCore.setOutput.secondCall.lastArg.length > 0, 'Time output a non-zero-length string'); - assert.equal(fakeCore.setOutput.lastCall.firstArg, 'time', 'Output name set to time'); - assert(fakeCore.setOutput.lastCall.lastArg.length > 0, 'Time output a non-zero-length string'); + assert.equal(fakeCore.exportVariable.firstCall.firstArg, 'ts', 'Output name set to ts'); + assert.equal(fakeCore.exportVariable.secondCall.firstArg, 'thread_ts', 'Output name set to thread_ts'); + assert(fakeCore.exportVariable.secondCall.lastArg.length > 0, 'Time output a non-zero-length string'); + assert.equal(fakeCore.exportVariable.lastCall.firstArg, 'time', 'Output name set to time'); + assert(fakeCore.exportVariable.lastCall.lastArg.length > 0, 'Time output a non-zero-length string'); const chatArgs = ChatStub.update.lastCall.firstArg; assert.equal(chatArgs.channel, 'C123456', 'Correct channel provided to postMessage'); assert.equal(chatArgs.text, 'who let the dogs out?', 'Correct message provided to postMessage'); @@ -93,11 +93,11 @@ describe('slack-send', () => { await slackSend(fakeCore); // Assert - assert.equal(fakeCore.setOutput.firstCall.firstArg, 'ts', 'Output name set to ts'); - assert.equal(fakeCore.setOutput.secondCall.firstArg, 'thread_ts', 'Output name set to thread_ts'); - assert(fakeCore.setOutput.secondCall.lastArg.length > 0, 'Time output a non-zero-length string'); - assert.equal(fakeCore.setOutput.lastCall.firstArg, 'time', 'Output name set to time'); - assert(fakeCore.setOutput.lastCall.lastArg.length > 0, 'Time output a non-zero-length string'); + assert.equal(fakeCore.exportVariable.firstCall.firstArg, 'ts', 'Output name set to ts'); + assert.equal(fakeCore.exportVariable.secondCall.firstArg, 'thread_ts', 'Output name set to thread_ts'); + assert(fakeCore.exportVariable.secondCall.lastArg.length > 0, 'Time output a non-zero-length string'); + assert.equal(fakeCore.exportVariable.lastCall.firstArg, 'time', 'Output name set to time'); + assert(fakeCore.exportVariable.lastCall.lastArg.length > 0, 'Time output a non-zero-length string'); const chatArgs = ChatStub.postMessage.lastCall.firstArg; assert.equal(chatArgs.channel, 'C123456', 'Correct channel provided to postMessage'); assert.equal(chatArgs.text, '', 'Correct message provided to postMessage');