Skip to content

Commit 4ef3776

Browse files
committed
Maintain backwards compatibility while making the ambiguity more clear
1 parent 02d60a9 commit 4ef3776

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

events/codepipeline.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package events
2+
3+
// CodePipelineJob has been incorrectly assigned as CodePipelineEvent
4+
// - https://github.com/aws/aws-lambda-go/issues/244
5+
// This maintains backwards compatability until a v2 release
6+
type CodePipelineEvent = CodePipelineJobEvent

events/codepipeline_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
package events
3+
4+
import (
5+
"encoding/json"
6+
"io/ioutil"
7+
"testing"
8+
9+
"github.com/aws/aws-lambda-go/events/test"
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestCodePipeLineJEventMarshaling(t *testing.T) {
14+
15+
// read json from file
16+
inputJSON, err := ioutil.ReadFile("./testdata/codepipeline-job-event.json")
17+
if err != nil {
18+
t.Errorf("could not open test file. details: %v", err)
19+
}
20+
21+
// de-serialize into CognitoEvent
22+
var inputEvent CodePipelineEvent
23+
if err := json.Unmarshal(inputJSON, &inputEvent); err != nil {
24+
t.Errorf("could not unmarshal event. details: %v", err)
25+
}
26+
27+
// serialize to json
28+
outputJSON, err := json.Marshal(inputEvent)
29+
if err != nil {
30+
t.Errorf("could not marshal event. details: %v", err)
31+
}
32+
33+
assert.JSONEq(t, string(inputJSON), string(outputJSON))
34+
}
35+
36+
func TestCodePipelineEventMarshalingMalformedJson(t *testing.T) {
37+
test.TestMalformedJson(t, CodePipelineEvent{})
38+
}

0 commit comments

Comments
 (0)