LB Type tests

Signed-off-by: aiordache <anca.iordache@docker.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
aiordache 2020-06-08 15:34:33 +02:00 committed by Nicolas De Loof
parent 1d11e847fb
commit 2c190f11f7
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 34 additions and 0 deletions

View File

@ -4,9 +4,13 @@ import (
"fmt"
"testing"
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/awslabs/goformation/v4/cloudformation"
"github.com/awslabs/goformation/v4/cloudformation/ec2"
"github.com/awslabs/goformation/v4/cloudformation/iam"
"github.com/awslabs/goformation/v4/cloudformation"
"github.com/awslabs/goformation/v4/cloudformation/elasticloadbalancingv2"
"github.com/compose-spec/compose-go/loader"
"github.com/compose-spec/compose-go/types"
"github.com/docker/ecs-plugin/pkg/compose"
@ -69,6 +73,36 @@ networks:
}
func TestLoadBalancerTypeApplication(t *testing.T) {
template := convertYaml(t, `
version: "3"
services:
test:
image: nginx
ports:
- 80:80
`)
lb := template.Resources["TestLoadBalancer"].(*elasticloadbalancingv2.LoadBalancer)
assert.Check(t, lb != nil)
assert.Check(t, lb.Type == elbv2.LoadBalancerTypeEnumApplication)
assert.Check(t, len(lb.SecurityGroups) > 0)
}
func TestLoadBalancerTypeNetwork(t *testing.T) {
template := convertYaml(t, `
version: "3"
services:
test:
image: nginx
ports:
- 80:80
- 88:88
`)
lb := template.Resources["TestLoadBalancer"].(*elasticloadbalancingv2.LoadBalancer)
assert.Check(t, lb != nil)
assert.Check(t, lb.Type == elbv2.LoadBalancerTypeEnumNetwork)
}
func convertResultAsString(t *testing.T, project *compose.Project, clusterName string) string {
client, err := NewClient("", clusterName, "")
assert.NilError(t, err)