mirror of https://github.com/docker/compose.git
Testcase to check resources get tagged
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
e2c903c85f
commit
2bc1b710f2
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue