mirror of
https://github.com/openfaas/faas.git
synced 2025-06-20 13:06:40 +00:00
Move handlers into ./handlers
This commit is contained in:
24
gateway/tests/alexhostname_request.json
Normal file
24
gateway/tests/alexhostname_request.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"session": {
|
||||
"sessionId": "SessionId.ea96e58d-dc16-43e1-b238-daac4541110c",
|
||||
"application": {
|
||||
"applicationId": "amzn1.ask.skill.72fb1025-aacc-4d05-a582-21344940c023"
|
||||
},
|
||||
"attributes": {},
|
||||
"user": {
|
||||
"userId": "amzn1.ask.account.AEN7KA5DBXAAWQPDUXTXFWBARZ5YZ6TNOQR5CUMV5LCCJTMBZVFP45SZVLGDD5GQBOM7QMELRS7LHG3F2FN2QQQMTBURDL5I4PQ33EHMNNGO4TXWG732Y6SDM2YZKHSPWIIWBH3GSE3Q3TTFAYN2Y66RHBKRANYCNMX2WORMASUGVRHUNBB4HZMJEC7HQDWUSXAOMP77WGJU4AY"
|
||||
},
|
||||
"new": true
|
||||
},
|
||||
"request": {
|
||||
"type": "IntentRequest",
|
||||
"requestId": "EdwRequestId.a934104e-3282-4620-b056-4aa4c5995503",
|
||||
"locale": "en-GB",
|
||||
"timestamp": "2016-12-07T15:50:01Z",
|
||||
"intent": {
|
||||
"name": "HostnameIntent",
|
||||
"slots": {}
|
||||
}
|
||||
},
|
||||
"version": "1.0"
|
||||
}
|
27
gateway/tests/isalexa_test.go
Normal file
27
gateway/tests/isalexa_test.go
Normal file
@ -0,0 +1,27 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/alexellis/faas/gateway/handlers"
|
||||
"github.com/alexellis/faas/gateway/requests"
|
||||
)
|
||||
|
||||
func TestIsAlexa(t *testing.T) {
|
||||
requestBody, _ := ioutil.ReadFile("./alexhostname_request.json")
|
||||
var result requests.AlexaRequestBody
|
||||
|
||||
result = handlers.IsAlexa(requestBody)
|
||||
|
||||
if len(result.Session.Application.ApplicationId) == 0 {
|
||||
t.Fail()
|
||||
}
|
||||
if len(result.Session.SessionId) == 0 {
|
||||
t.Fail()
|
||||
}
|
||||
if len(result.Request.Intent.Name) == 0 {
|
||||
t.Fail()
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package requests
|
||||
package tests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"io/ioutil"
|
||||
@ -11,6 +10,7 @@ import (
|
||||
"github.com/alexellis/faas/gateway/requests"
|
||||
)
|
||||
|
||||
// TestUnmarshallAlert is an exploratory test from TDD'ing the struct to parse a Prometheus alert
|
||||
func TestUnmarshallAlert(t *testing.T) {
|
||||
file, _ := ioutil.ReadFile("./test_alert.json")
|
||||
|
||||
@ -19,7 +19,6 @@ func TestUnmarshallAlert(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println("OK", string(file), alert)
|
||||
if (len(alert.Status)) == 0 {
|
||||
t.Fatal("No status read")
|
||||
}
|
||||
|
Reference in New Issue
Block a user