forked from aws/aws-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into document_validate
- Loading branch information
Showing
140 changed files
with
64,921 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package router_test | ||
|
||
import ( | ||
"github.com/awslabs/aws-sam-local/router" | ||
"github.com/awslabs/goformation/cloudformation" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func getApiResourceFromTemplate(path string) *router.AWSServerlessApi { | ||
templateUri := &path | ||
apiResource := &router.AWSServerlessApi{ | ||
AWSServerlessApi: &cloudformation.AWSServerlessApi{ | ||
DefinitionUri: &cloudformation.AWSServerlessApi_DefinitionUri{ | ||
String: templateUri, | ||
}, | ||
}, | ||
} | ||
return apiResource | ||
} | ||
|
||
var _ = Describe("Api", func() { | ||
|
||
Context("Load local Swagger definitions", func() { | ||
It("Succesfully loads the basic template", func() { | ||
apiResource := getApiResourceFromTemplate("../test/templates/open-api/pet-store-simple.json") | ||
|
||
mounts, err := apiResource.Mounts() | ||
|
||
Expect(err).Should(BeNil()) | ||
Expect(mounts).ShouldNot(BeNil()) | ||
|
||
Expect(mounts).ShouldNot(BeEmpty()) | ||
Expect(len(mounts)).Should(BeIdenticalTo(4)) | ||
}) | ||
|
||
It("Succesfully reads integration definition", func() { | ||
apiResource := getApiResourceFromTemplate("../test/templates/open-api/pet-store-simple.json") | ||
|
||
mounts, err := apiResource.Mounts() | ||
|
||
Expect(err).Should(BeNil()) | ||
Expect(mounts).ShouldNot(BeNil()) | ||
|
||
for _, mount := range mounts { | ||
if mount.Method == "get" && mount.Path == "/pets" { | ||
Expect(mount.IntegrationArn.Arn).Should(BeIdenticalTo("arn:aws:lambda:us-west-2:123456789012:function:Calc")) | ||
} | ||
} | ||
}) | ||
|
||
It("Loads the proxy template", func() { | ||
apiResource := getApiResourceFromTemplate("../test/templates/open-api/pet-store-proxy.json") | ||
|
||
mounts, err := apiResource.Mounts() | ||
|
||
Expect(err).Should(BeNil()) | ||
Expect(mounts).ShouldNot(BeNil()) | ||
// we expect 9 here because the any method should generate all 7 | ||
Expect(len(mounts)).To(BeIdenticalTo(9)) | ||
|
||
for _, mount := range mounts { | ||
if mount.Method == "post" && mount.Path == "/pets/{proxy+}" { | ||
Expect(mount.IntegrationArn.Arn).Should(ContainSubstring("AnyMethod")) | ||
} | ||
if mount.Method == "delete" && mount.Path == "/pets/{proxy+}" { | ||
Expect(mount.IntegrationArn.Arn).Should(ContainSubstring("Calc")) | ||
} | ||
} | ||
}) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.