Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use method core.exportVariable instead of core.set-output #142

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/slack-send.js
Expand Up @@ -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);
}
Expand Down
30 changes: 15 additions & 15 deletions test/slack-send-test.js
Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down