Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions events/cloudwatch_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type CloudWatchEvent struct {
Region string `json:"region"`
Resources []string `json:"resources"`
Detail json.RawMessage `json:"detail"`
ReplayName string `json:"replay-name,omitempty"` // set only on events replayed from an archive
}

type EventBridgeEvent = CloudWatchEvent
25 changes: 25 additions & 0 deletions events/cloudwatch_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,31 @@ func TestCloudwatchScheduledEventIdempotency(t *testing.T) {
assert.JSONEq(t, string(inputJSON), string(outputJSON))
}

func TestCloudwatchReplayedEventIdempotency(t *testing.T) {
inputJSON := []byte(
"{\"version\":\"0\",\"id\":\"890abcde-f123-4567-890a-bcdef1234567\"," +
"\"detail-type\":\"Scheduled Event\",\"source\":\"aws.events\"," +
"\"account\":\"123456789012\",\"time\":\"2016-12-30T18:44:49Z\"," +
"\"region\":\"us-east-1\"," +
"\"resources\":[\"arn:aws:events:us-east-1:123456789012:rule/SampleRule\"]," +
"\"detail\":{},\"replay-name\":\"my-replay\"}")

var inputEvent CloudWatchEvent
err := json.Unmarshal(inputJSON, &inputEvent)
if err != nil {
t.Errorf("Could not unmarshal replayed event: %v", err)
}

assert.Equal(t, "my-replay", inputEvent.ReplayName)

outputJSON, err := json.Marshal(inputEvent)
if err != nil {
t.Errorf("Could not marshal replayed event: %v", err)
}

assert.JSONEq(t, string(inputJSON), string(outputJSON))
}

func TestCloudwatchScheduledEventRequestMalformedJson(t *testing.T) {
test.TestMalformedJson(t, &CloudWatchEvent{})
}
Loading