Skip to content

Commit 151e061

Browse files
authored
Merge branch 'master' into master
2 parents 5d6f36f + ee817dd commit 151e061

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

events/codepipeline.go

+6
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_job.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
package events
44

5-
// CodePipelineEvent contains data from an event sent from AWS Codepipeline
6-
type CodePipelineEvent struct {
5+
// CodePipelineJobEvent contains data from an event sent from AWS CodePipeline
6+
type CodePipelineJobEvent struct {
77
CodePipelineJob CodePipelineJob `json:"CodePipeline.job"`
88
}
99

events/codepipeline_job_test.go

+38
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 TestCodePipeLineJobEventMarshaling(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 CodePipelineJobEvent
22+
var inputEvent CodePipelineJobEvent
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 TestCodePipelineJobEventMarshalingMalformedJson(t *testing.T) {
37+
test.TestMalformedJson(t, CodePipelineJobEvent{})
38+
}

events/codepipeline_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
func TestCodePipeLineEventMarshaling(t *testing.T) {
1414

1515
// read json from file
16-
inputJSON, err := ioutil.ReadFile("./testdata/codepipline-event.json")
16+
inputJSON, err := ioutil.ReadFile("./testdata/codepipeline-job-event.json")
1717
if err != nil {
1818
t.Errorf("could not open test file. details: %v", err)
1919
}

0 commit comments

Comments
 (0)