Testcase to check resources get tagged

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-06-30 15:52:04 +02:00
parent e2c903c85f
commit 2bc1b710f2
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 28 additions and 0 deletions

View File

@ -2,8 +2,11 @@ package backend
import (
"fmt"
"reflect"
"testing"
"github.com/docker/ecs-plugin/pkg/compose"
"github.com/aws/aws-sdk-go/service/elbv2"
"github.com/awslabs/goformation/v4/cloudformation"
"github.com/awslabs/goformation/v4/cloudformation/ec2"
@ -105,6 +108,31 @@ services:
assert.Check(t, lb.Type == elbv2.LoadBalancerTypeEnumNetwork)
}
func TestResourcesHaveProjectTagSet(t *testing.T) {
template := convertYaml(t, `
version: "3"
services:
test:
image: nginx
ports:
- 80:80
- 88:88
`)
for _, r := range template.Resources {
tags := reflect.Indirect(reflect.ValueOf(r)).FieldByName("Tags")
if !tags.IsValid() {
continue
}
for i := 0; i < tags.Len(); i++ {
k := tags.Index(i).FieldByName("Key").String()
v := tags.Index(i).FieldByName("Value").String()
if k == compose.ProjectTag {
assert.Equal(t, v, "Test")
}
}
}
}
func convertResultAsString(t *testing.T, project *types.Project, clusterName string) string {
client, err := NewBackend("", clusterName, "")
assert.NilError(t, err)