-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8db48d
commit 115b15e
Showing
14 changed files
with
612 additions
and
84 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env tsx | ||
|
||
import { exec } from "child_process"; | ||
import { buildMessageBody } from "../src/modules/email/test.util"; | ||
|
||
const messageBody = JSON.stringify(buildMessageBody({ | ||
body: "What tools are available", | ||
from: "[email protected]", | ||
subject: "Subject", | ||
to: [ "[email protected]" ] | ||
})); | ||
|
||
// Define the AWS CLI command | ||
const region = "us-west-2"; | ||
const endpoint = "http://localhost:9324"; | ||
const queueUrl = "http://localhost:9324/000000000000/email-ingestion"; | ||
const command = `aws --region=${region} --endpoint=${endpoint} sqs send-message --queue-url ${queueUrl} --message-body '${messageBody}'`; | ||
|
||
// Execute the AWS CLI command | ||
exec(command, (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`Error executing command: ${error.message}`); | ||
return; | ||
} | ||
if (stderr) { | ||
console.error(`stderr: ${stderr}`); | ||
return; | ||
} | ||
console.log(`stdout: ${stdout}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ulid } from "ulid"; | ||
import { parseMessage } from "."; | ||
import { createOwner } from "../test/util"; | ||
import { buildMessageBody } from "./test.util"; | ||
|
||
|
||
describe("parseMessage", () => { | ||
const clusterId = ulid(); | ||
const organizationId = ulid(); | ||
|
||
beforeAll(async () => { | ||
await createOwner({ | ||
clusterId, | ||
organizationId, | ||
}); | ||
}) | ||
|
||
it("should parse a message ingestion event", async () => { | ||
const result = await parseMessage(buildMessageBody({ | ||
from: "[email protected]", | ||
to: [ `${clusterId}@run.inferable.ai` ], | ||
subject: "Subject", | ||
body: "What tools are available" | ||
})); | ||
|
||
expect(result).toBeDefined(); | ||
expect(result.clusterId).toBe(clusterId); | ||
expect(result.source).toBe("[email protected]"); | ||
}); | ||
|
||
it("should fail with multiple '@run.inferable.ai' addresses", async () => { | ||
await expect(parseMessage(buildMessageBody({ | ||
from: "[email protected]", | ||
to: [ "[email protected]", `${clusterId}@run.inferable.ai` ], | ||
subject: "Subject", | ||
body: "What tools are available" | ||
}))).rejects.toThrow("Found multiple Inferable email addresses in destination"); | ||
}) | ||
|
||
it("should fail with no '@run.inferable.ai' addresses", async () => { | ||
await expect(parseMessage(buildMessageBody({ | ||
from: "[email protected]", | ||
to: [ "[email protected]" ], | ||
subject: "Subject", | ||
body: "What tools are available" | ||
}))).rejects.toThrow("Could not extract clusterId from email address"); | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.