-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_test.go
More file actions
37 lines (34 loc) · 832 Bytes
/
main_test.go
File metadata and controls
37 lines (34 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main_test
import (
"github.com/aws/aws-lambda-go/events"
main "github.com/hackersandslackers/go-lambda-function-tutorial"
"github.com/stretchr/testify/assert"
"log"
"testing"
)
func TestHandler(t *testing.T) {
tests := []struct {
request events.APIGatewayProxyRequest
expect string
err error
}{
{
// Test name has value
request: events.APIGatewayProxyRequest{QueryStringParameters: map[string]string{"name": "Paul"}},
expect: "Hello Paul!",
err: nil,
},
{
// Test name is null
request: events.APIGatewayProxyRequest{},
expect: "Hello !",
err: nil,
},
}
for i, test := range tests {
response, err := main.Handler(test.request)
assert.IsType(t, test.err, err)
assert.Equal(t, test.expect, response.Body)
log.Printf("Test %d: %s", i, response.Body)
}
}