Skip to content

Commit

Permalink
Merge pull request #462 from bmoffatt/main
Browse files Browse the repository at this point in the history
add 1.19 to the unit test matrix
  • Loading branch information
carlzogh authored Aug 11, 2022
2 parents 13ee405 + 69f2b2a commit 4c09e84
Show file tree
Hide file tree
Showing 35 changed files with 95 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:

- name: golangci-golint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.45.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.48.0
./bin/golangci-lint run -v ./...
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
strategy:
matrix:
go:
- "1.19"
- "1.18"
- "1.17"
- "1.16"
Expand Down
2 changes: 1 addition & 1 deletion cfn/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package cfn

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion cfn/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"log"
"net/http"
)
Expand Down
14 changes: 7 additions & 7 deletions cfn/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ func lambdaWrapWithClient(lambdaFunction CustomResourceFunction, client httpClie
// plate is taken away from the customer and it makes writing a Custom Resource
// simpler.
//
// func myLambda(ctx context.Context, event cfn.Event) (physicalResourceID string, data map[string]interface{}, err error) {
// physicalResourceID = "arn:...."
// return
// }
// func myLambda(ctx context.Context, event cfn.Event) (physicalResourceID string, data map[string]interface{}, err error) {
// physicalResourceID = "arn:...."
// return
// }
//
// func main() {
// lambda.Start(cfn.LambdaWrap(myLambda))
// }
// func main() {
// lambda.Start(cfn.LambdaWrap(myLambda))
// }
func LambdaWrap(lambdaFunction CustomResourceFunction) (fn CustomResourceLambdaFunction) {
return lambdaWrapWithClient(lambdaFunction, http.DefaultClient)
}
Expand Down
2 changes: 1 addition & 1 deletion cfn/wrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"encoding/json"
"errors"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"net/http"
"testing"

Expand Down
2 changes: 1 addition & 1 deletion cmd/build-lambda-zip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"archive/zip"
"flag"
"fmt"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"log"
"os"
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion cmd/build-lambda-zip/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package main
import (
"archive/zip"
"fmt"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"os"
"os/exec"
"path"
Expand Down
4 changes: 2 additions & 2 deletions cmd/build-lambda-zip/testdata/apigw.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/aws/aws-lambda-go/lambda"
)

func main () {
lambda.Start(func (ctx context.Context, event events.APIGatewayV2HTTPRequest) (*events.APIGatewayProxyResponse, error) {
func main() {
lambda.Start(func(ctx context.Context, event events.APIGatewayV2HTTPRequest) (*events.APIGatewayProxyResponse, error) {
return &events.APIGatewayProxyResponse{
Body: fmt.Sprintf("Hello %v", event),
}, nil
Expand Down
3 changes: 2 additions & 1 deletion cmd/build-lambda-zip/testdata/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
)

type BinaryHandler func(context.Context, []byte) ([]byte, error)

func (bh BinaryHandler) Invoke(ctx context.Context, req []byte) ([]byte, error) {
return bh(ctx, req)
}

func noop (ctx context.Context, req []byte) ([]byte, error) {
func noop(ctx context.Context, req []byte) ([]byte, error) {
return req, nil
}

Expand Down
2 changes: 1 addition & 1 deletion events/alb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/apigw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/appsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/clientvpn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/codebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ type CodeBuildEventDetail struct {
CompletedPhaseEnd CodeBuildTime `json:"completed-phase-end"`
}

//CodeBuildEventAdditionalInformation represents additional information to the code build event
// CodeBuildEventAdditionalInformation represents additional information to the code build event
type CodeBuildEventAdditionalInformation struct {
Artifact CodeBuildArtifact `json:"artifact"`

Expand Down
2 changes: 1 addition & 1 deletion events/codebuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"
"time"

Expand Down
2 changes: 1 addition & 1 deletion events/codedeploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package events
import (
"encoding/json"
"github.com/stretchr/testify/require"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"
"time"
)
Expand Down
3 changes: 2 additions & 1 deletion events/codepipeline.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package events

// CodePipelineJob has been incorrectly assigned as CodePipelineEvent
// - https://github.com/aws/aws-lambda-go/issues/244
// - https://github.com/aws/aws-lambda-go/issues/244
//
// This maintains backwards compatability until a v2 release
type CodePipelineEvent = CodePipelineJobEvent
2 changes: 1 addition & 1 deletion events/codepipeline_cloudwatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package events
import (
"encoding/json"
"github.com/stretchr/testify/require"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"
"time"
)
Expand Down
2 changes: 1 addition & 1 deletion events/codepipeline_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/codepipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/cognito_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/iot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/aws/aws-lambda-go/events/test"
Expand Down
2 changes: 1 addition & 1 deletion events/lambda_function_urls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package events

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/stretchr/testify/assert"
Expand Down
6 changes: 3 additions & 3 deletions events/test/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package test

import (
"encoding/json"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"

"github.com/stretchr/testify/assert"
)

//nolint: stylecheck
// nolint: stylecheck
func AssertJsonFile(t *testing.T, file string, o interface{}) {
inputJSON, err := ioutil.ReadFile(file)
if err != nil {
Expand All @@ -17,7 +17,7 @@ func AssertJsonFile(t *testing.T, file string, o interface{}) {
AssertJsonBytes(t, inputJSON, o)
}

//nolint: stylecheck
// nolint: stylecheck
func AssertJsonBytes(t *testing.T, inputJSON []byte, o interface{}) {
// de-serialize
if err := json.Unmarshal(inputJSON, o); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion events/test/jsonblobs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package test

//nolint: stylecheck
// nolint: stylecheck
func GetMalformedJson() []byte {
return []byte(`{ "Records`)
}
2 changes: 1 addition & 1 deletion events/test/jsonsyntax.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
)

//nolint: stylecheck
// nolint: stylecheck
func TestMalformedJson(t *testing.T, objectToDeserialize interface{}) {
// 1. read JSON from file
inputJson := GetMalformedJson()
Expand Down
2 changes: 1 addition & 1 deletion events/test/readjson.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package test

import (
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"testing"
)

Expand Down
34 changes: 17 additions & 17 deletions lambda/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import (
//
// Rules:
//
// * handler must be a function
// * handler may take between 0 and two arguments.
// * if there are two arguments, the first argument must satisfy the "context.Context" interface.
// * handler may return between 0 and two arguments.
// * if there are two return values, the second argument must be an error.
// * if there is one return value it must be an error.
// - handler must be a function
// - handler may take between 0 and two arguments.
// - if there are two arguments, the first argument must satisfy the "context.Context" interface.
// - handler may return between 0 and two arguments.
// - if there are two return values, the second argument must be an error.
// - if there is one return value it must be an error.
//
// Valid function signatures:
//
// func ()
// func () error
// func (TIn) error
// func () (TOut, error)
// func (TIn) (TOut, error)
// func (context.Context) error
// func (context.Context, TIn) error
// func (context.Context) (TOut, error)
// func (context.Context, TIn) (TOut, error)
// func ()
// func () error
// func (TIn) error
// func () (TOut, error)
// func (TIn) (TOut, error)
// func (context.Context) error
// func (context.Context, TIn) error
// func (context.Context) (TOut, error)
// func (context.Context, TIn) (TOut, error)
//
// Where "TIn" and "TOut" are types compatible with the "encoding/json" standard library.
// See https://golang.org/pkg/encoding/json/#Unmarshal for how deserialization behaves
Expand All @@ -51,7 +51,7 @@ func StartWithContext(ctx context.Context, handler interface{}) {
//
// Handler implementation requires a single "Invoke()" function:
//
// func Invoke(context.Context, []byte) ([]byte, error)
// func Invoke(context.Context, []byte) ([]byte, error)
//
// Deprecated: use lambda.Start(handler) instead
func StartHandler(handler Handler) {
Expand Down Expand Up @@ -83,7 +83,7 @@ var (
//
// Handler implementation requires a single "Invoke()" function:
//
// func Invoke(context.Context, []byte) ([]byte, error)
// func Invoke(context.Context, []byte) ([]byte, error)
//
// Deprecated: use lambda.StartWithOptions(handler, lambda.WithContext(ctx)) instead
func StartHandlerWithContext(ctx context.Context, handler Handler) {
Expand Down
2 changes: 1 addition & 1 deletion lambda/extensions_api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"io/ioutil" //nolint: staticcheck
"net/http"
)

Expand Down
Loading

0 comments on commit 4c09e84

Please sign in to comment.