driftctl/pkg/middlewares/default_vpc_test.go

60 lines
1.2 KiB
Go
Raw Normal View History

2020-12-15 10:07:03 +00:00
package middlewares
import (
"testing"
"github.com/cloudskiff/driftctl/pkg/resource/aws"
"github.com/cloudskiff/driftctl/pkg/resource"
)
func TestAwsDefaultVPCShouldBeIgnored(t *testing.T) {
middleware := NewAwsDefaultVPC()
remoteResources := []resource.Resource{
2021-05-10 16:02:57 +00:00
&resource.AbstractResource{
Id: "foobar",
Type: aws.AwsDefaultVpcResourceType,
Attrs: &resource.Attributes{
"id": "foobar",
},
2020-12-15 10:07:03 +00:00
},
}
stateResources := []resource.Resource{}
err := middleware.Execute(&remoteResources, &stateResources)
if err != nil {
t.Error(err)
}
if len(remoteResources) != 0 {
t.Error("Default VPC was not ignored")
}
}
func TestAwsDefaultVPCShouldNotBeIgnoredWhenManaged(t *testing.T) {
middleware := NewAwsDefaultVPC()
remoteResources := []resource.Resource{
2021-05-10 16:02:57 +00:00
&resource.AbstractResource{
Id: "foobar",
Type: aws.AwsDefaultVpcResourceType,
Attrs: &resource.Attributes{
"id": "foobar",
},
2020-12-15 10:07:03 +00:00
},
}
stateResources := []resource.Resource{
&aws.AwsDefaultVpc{
Id: "foobar",
},
}
err := middleware.Execute(&remoteResources, &stateResources)
if err != nil {
t.Error(err)
}
if len(remoteResources) != 1 {
t.Error("Default VPC was ignored")
}
}