Browse Source

LB Type tests

Signed-off-by: aiordache <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
aiordache 5 years ago
parent
commit
2c190f11f7
1 changed files with 34 additions and 0 deletions
  1. 34 0
      ecs/pkg/amazon/cloudformation_test.go

+ 34 - 0
ecs/pkg/amazon/cloudformation_test.go

@@ -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)