MCPcopy Create free account
hub / github.com/AdRoll/baker / TestSQSParseMessage

Function TestSQSParseMessage

input/sqs_test.go:27–265  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestSQSParseMessage(t *testing.T) {
28 tests := []struct {
29 name string
30 queues []string
31 format, message, expression string
32 wantPath string
33 wantConfigErr, wantParseErr bool
34 }{
35 {
36 queues: []string{"some-queue"},
37 format: "plain",
38 message: "s3://some-bucket/with/stuff/inside",
39 wantPath: "s3://some-bucket/with/stuff/inside",
40 },
41 {
42 queues: []string{"some-queue"},
43 format: "sns",
44 message: `
45 {
46 "Type" : "Notification",
47 "Message" : "s3://another-bucket/path/to/file",
48 "Timestamp" : "2023-05-22T23:21:09.550Z"
49 }`,
50 wantPath: "s3://another-bucket/path/to/file",
51 },
52 {
53 queues: []string{"some-queue"},
54 format: "json",
55 expression: "Foo.Bar",
56 message: `
57 {
58 "Type": "Notification",
59 "Foo": {
60 "Bar": "s3://another-bucket/path/to/file"
61 }
62 }`,
63 wantPath: "s3://another-bucket/path/to/file",
64 },
65 {
66 queues: []string{"some-queue"},
67 format: "s3::ObjectCreated",
68 expression: "Records[*].join('/',['s3:/', s3.bucket.name, s3.object.key]) | [0]",
69 message: `
70 {
71 "Records": [
72 {
73 "eventVersion": "2.1",
74 "eventSource": "aws:s3",
75 "awsRegion": "us-west-2",
76 "eventTime": "2021-08-29T11:52:17.371Z",
77 "eventName": "ObjectCreated:Put",
78 "userIdentity": {
79 "principalId": "REDACTED"
80 },
81 "requestParameters": {
82 "sourceIPAddress": "172.18.206.6"
83 },
84 "responseElements": {

Callers

nothing calls this directly

Calls 2

NewSQSFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected