Compare commits
2 Commits
v1.0.18
...
slackme/ex
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd3d42d54e | ||
|
|
66f1c3b97c |
@@ -56,6 +56,15 @@ describe("slackme", async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("exits with command code", async () => {
|
||||||
|
const { instance, id } = await setupContainer();
|
||||||
|
await writeCoder(id, "echo 'some-url' && exit 1");
|
||||||
|
let exec = await execContainer(id, ["sh", "-c", instance.script]);
|
||||||
|
expect(exec.exitCode).toBe(0);
|
||||||
|
exec = await execContainer(id, ["sh", "-c", "slackme exit 1"]);
|
||||||
|
expect(exec.exitCode).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("formats multiline message", async () => {
|
it("formats multiline message", async () => {
|
||||||
await assertSlackMessage({
|
await assertSlackMessage({
|
||||||
command: "echo test",
|
command: "echo test",
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ fi
|
|||||||
|
|
||||||
START=$(date +%s%N)
|
START=$(date +%s%N)
|
||||||
# Run all arguments as a command
|
# Run all arguments as a command
|
||||||
$@
|
"$@"
|
||||||
|
CODE=$?
|
||||||
END=$(date +%s%N)
|
END=$(date +%s%N)
|
||||||
DURATION_MS=$${DURATION_MS:-$(( (END - START) / 1000000 ))}
|
DURATION_MS=$${DURATION_MS:-$(( (END - START) / 1000000 ))}
|
||||||
PRETTY_DURATION=$(pretty_duration $DURATION_MS)
|
PRETTY_DURATION=$(pretty_duration $DURATION_MS)
|
||||||
@@ -85,3 +86,5 @@ SLACK_MESSAGE=$(echo "$SLACK_MESSAGE" | sed "s|\\$DURATION|$PRETTY_DURATION|g")
|
|||||||
curl --silent -o /dev/null --header "Authorization: Bearer $BOT_TOKEN" \
|
curl --silent -o /dev/null --header "Authorization: Bearer $BOT_TOKEN" \
|
||||||
-G --data-urlencode "text=$${SLACK_MESSAGE}" \
|
-G --data-urlencode "text=$${SLACK_MESSAGE}" \
|
||||||
"$SLACK_URL/api/chat.postMessage?channel=$USER_ID&pretty=1"
|
"$SLACK_URL/api/chat.postMessage?channel=$USER_ID&pretty=1"
|
||||||
|
|
||||||
|
exit $CODE
|
||||||
|
|||||||
Reference in New Issue
Block a user