pull/85/head
Kyle Carberry 2 years ago
parent 610947eefb
commit 94115c967e

@ -12,7 +12,7 @@ tags: [helper]
Add the `slackme` command to your workspace that DMs you on Slack when your command finishes running. Add the `slackme` command to your workspace that DMs you on Slack when your command finishes running.
```bash ```bash
$ slackme npm run long-build $ slackme npm run long-build
``` ```
## Setup ## Setup

@ -1,6 +1,6 @@
import { describe, expect, it } from "bun:test"; import { describe, expect, it } from "bun:test";
import { import {
createJSONResponse, createJSONResponse,
execContainer, execContainer,
executeScriptInContainer, executeScriptInContainer,
findResourceInstance, findResourceInstance,
@ -55,7 +55,7 @@ describe("slackme", async () => {
expect(exec.exitCode).toBe(0); expect(exec.exitCode).toBe(0);
exec = await execContainer(id, ["sh", "-c", "slackme"]); exec = await execContainer(id, ["sh", "-c", "slackme"]);
expect(exec.stdout.trim()).toStartWith( expect(exec.stdout.trim()).toStartWith(
"slackme — Send a Slack notification when a command finishes" "slackme — Send a Slack notification when a command finishes",
); );
}); });
@ -69,7 +69,7 @@ describe("slackme", async () => {
}); });
it("curls url when authenticated", async () => { it("curls url when authenticated", async () => {
let url: URL let url: URL;
const fakeSlackHost = serve({ const fakeSlackHost = serve({
fetch: (req) => { fetch: (req) => {
url = new URL(req.url); url = new URL(req.url);
@ -86,7 +86,11 @@ describe("slackme", async () => {
await writeCoder(id, "echo 'token'"); await writeCoder(id, "echo 'token'");
let exec = await execContainer(id, ["sh", "-c", instance.script]); let exec = await execContainer(id, ["sh", "-c", instance.script]);
expect(exec.exitCode).toBe(0); expect(exec.exitCode).toBe(0);
exec = await execContainer(id, ["sh", "-c", `SLACK_URL="http://${fakeSlackHost.hostname}:${fakeSlackHost.port}" slackme echo test`]); exec = await execContainer(id, [
"sh",
"-c",
`SLACK_URL="http://${fakeSlackHost.hostname}:${fakeSlackHost.port}" slackme echo test`,
]);
expect(exec.stdout.trim()).toEndWith("test"); expect(exec.stdout.trim()).toEndWith("test");
expect(url.pathname).toEqual("/api/chat.postMessage"); expect(url.pathname).toEqual("/api/chat.postMessage");
expect(url.searchParams.get("channel")).toEqual("token"); expect(url.searchParams.get("channel")).toEqual("token");

Loading…
Cancel
Save