@@ -12,17 +12,42 @@ import (
12
12
. "github.com/onsi/gomega"
13
13
)
14
14
15
+ type handler struct {}
16
+
17
+ func (h handler ) ServeHTTP (w http.ResponseWriter , req * http.Request ) {
18
+ w .Header ().Add ("unfortunately-required-header" , "" )
19
+ fmt .Fprintf (w , "Go Lambda!!" )
20
+ }
21
+
15
22
var _ = Describe ("HandlerFuncAdapter tests" , func () {
16
- Context ("Simple ping request" , func () {
23
+ Context ("Simple ping request, HandlerFunc " , func () {
17
24
It ("Proxies the event correctly" , func () {
18
25
log .Println ("Starting test" )
19
26
20
- handler := func (w http.ResponseWriter , req * http.Request ) {
27
+ handlerFunc := func (w http.ResponseWriter , req * http.Request ) {
21
28
w .Header ().Add ("unfortunately-required-header" , "" )
22
29
fmt .Fprintf (w , "Go Lambda!!" )
23
30
}
24
31
25
- adapter := handlerfunc .New (handler )
32
+ adapter := handlerfunc .New (handlerFunc )
33
+
34
+ req := events.APIGatewayProxyRequest {
35
+ Path : "/ping" ,
36
+ HTTPMethod : "GET" ,
37
+ }
38
+
39
+ resp , err := adapter .Proxy (req )
40
+
41
+ Expect (err ).To (BeNil ())
42
+ Expect (resp .StatusCode ).To (Equal (200 ))
43
+ })
44
+ })
45
+
46
+ Context ("Simple ping request, Handler" , func () {
47
+ It ("Proxies the event correctly" , func () {
48
+ log .Println ("Starting test" )
49
+
50
+ adapter := handlerfunc .NewHandler (handler {})
26
51
27
52
req := events.APIGatewayProxyRequest {
28
53
Path : "/ping" ,
0 commit comments