Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ianpyw committed Jul 29, 2021
2 parents 5d6f36f + ee817dd commit 151e061
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
6 changes: 6 additions & 0 deletions events/codepipeline.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package events

// CodePipelineJob has been incorrectly assigned as CodePipelineEvent
// - https://github.com/aws/aws-lambda-go/issues/244
// This maintains backwards compatability until a v2 release
type CodePipelineEvent = CodePipelineJobEvent
4 changes: 2 additions & 2 deletions events/codepipeline_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

package events

// CodePipelineEvent contains data from an event sent from AWS Codepipeline
type CodePipelineEvent struct {
// CodePipelineJobEvent contains data from an event sent from AWS CodePipeline
type CodePipelineJobEvent struct {
CodePipelineJob CodePipelineJob `json:"CodePipeline.job"`
}

Expand Down
38 changes: 38 additions & 0 deletions events/codepipeline_job_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
package events

import (
"encoding/json"
"io/ioutil"
"testing"

"github.com/aws/aws-lambda-go/events/test"
"github.com/stretchr/testify/assert"
)

func TestCodePipeLineJobEventMarshaling(t *testing.T) {

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

// de-serialize into CodePipelineJobEvent
var inputEvent CodePipelineJobEvent
if err := json.Unmarshal(inputJSON, &inputEvent); err != nil {
t.Errorf("could not unmarshal event. details: %v", err)
}

// serialize to json
outputJSON, err := json.Marshal(inputEvent)
if err != nil {
t.Errorf("could not marshal event. details: %v", err)
}

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

func TestCodePipelineJobEventMarshalingMalformedJson(t *testing.T) {
test.TestMalformedJson(t, CodePipelineJobEvent{})
}
2 changes: 1 addition & 1 deletion events/codepipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestCodePipeLineEventMarshaling(t *testing.T) {

// read json from file
inputJSON, err := ioutil.ReadFile("./testdata/codepipline-event.json")
inputJSON, err := ioutil.ReadFile("./testdata/codepipeline-job-event.json")
if err != nil {
t.Errorf("could not open test file. details: %v", err)
}
Expand Down
File renamed without changes.

0 comments on commit 151e061

Please sign in to comment.