test: google_compute_network
parent
8f21018259
commit
8cd318ea68
|
@ -25,7 +25,7 @@ func Test_assetRepository_searchAllResources_CacheHit(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &cache.MockCache{}
|
c := &cache.MockCache{}
|
||||||
c.On("Get", "googleSearchAllResources").Return(expectedResults).Times(1)
|
c.On("Get", "SearchAllResources").Return(expectedResults).Times(1)
|
||||||
repo := NewAssetRepository(nil, config.GCPTerraformConfig{Project: ""}, c)
|
repo := NewAssetRepository(nil, config.GCPTerraformConfig{Project: ""}, c)
|
||||||
|
|
||||||
got, err := repo.searchAllResources("google_fake_type")
|
got, err := repo.searchAllResources("google_fake_type")
|
||||||
|
@ -51,8 +51,8 @@ func Test_assetRepository_searchAllResources_CacheMiss(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
c := &cache.MockCache{}
|
c := &cache.MockCache{}
|
||||||
c.On("Get", "googleSearchAllResources").Return(nil).Times(1)
|
c.On("Get", "SearchAllResources").Return(nil).Times(1)
|
||||||
c.On("Put", "googleSearchAllResources", mock.IsType([]*assetpb.ResourceSearchResult{})).Return(false).Times(1)
|
c.On("Put", "SearchAllResources", mock.IsType([]*assetpb.ResourceSearchResult{})).Return(false).Times(1)
|
||||||
repo := NewAssetRepository(assetClient, config.GCPTerraformConfig{Project: ""}, c)
|
repo := NewAssetRepository(assetClient, config.GCPTerraformConfig{Project: ""}, c)
|
||||||
|
|
||||||
got, err := repo.searchAllResources("google_fake_type")
|
got, err := repo.searchAllResources("google_fake_type")
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package remote
|
package remote
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
asset "cloud.google.com/go/asset/apiv1"
|
|
||||||
"github.com/cloudskiff/driftctl/mocks"
|
"github.com/cloudskiff/driftctl/mocks"
|
||||||
"github.com/cloudskiff/driftctl/pkg/filter"
|
"github.com/cloudskiff/driftctl/pkg/filter"
|
||||||
"github.com/cloudskiff/driftctl/pkg/remote/alerts"
|
"github.com/cloudskiff/driftctl/pkg/remote/alerts"
|
||||||
|
@ -460,14 +458,10 @@ func TestGoogleComputeNetwork(t *testing.T) {
|
||||||
c.setupAlerterMock(alerter)
|
c.setupAlerterMock(alerter)
|
||||||
}
|
}
|
||||||
|
|
||||||
var assetClient *asset.Client
|
assetClient, err := testgoogle.NewFakeAssetServer(c.response, c.responseErr)
|
||||||
if !shouldUpdate {
|
|
||||||
var err error
|
|
||||||
assetClient, err = testgoogle.NewFakeAssetServer(c.response, c.responseErr)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tt.Fatal(err)
|
tt.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion)
|
realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -478,11 +472,6 @@ func TestGoogleComputeNetwork(t *testing.T) {
|
||||||
|
|
||||||
// Replace mock by real resources if we are in update mode
|
// Replace mock by real resources if we are in update mode
|
||||||
if shouldUpdate {
|
if shouldUpdate {
|
||||||
ctx := context.Background()
|
|
||||||
assetClient, err = asset.NewClient(ctx)
|
|
||||||
if err != nil {
|
|
||||||
tt.Fatal(err)
|
|
||||||
}
|
|
||||||
err = realProvider.Init()
|
err = realProvider.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tt.Fatal(err)
|
tt.Fatal(err)
|
||||||
|
|
|
@ -9,6 +9,7 @@ func initGoogleComputeNetworkMetadata(resourceSchemaRepository resource.SchemaRe
|
||||||
res.Attributes().SafeDelete([]string{"timeouts"})
|
res.Attributes().SafeDelete([]string{"timeouts"})
|
||||||
res.Attributes().SafeDelete([]string{"self_link"})
|
res.Attributes().SafeDelete([]string{"self_link"})
|
||||||
res.Attributes().SafeDelete([]string{"gateway_ipv4"})
|
res.Attributes().SafeDelete([]string{"gateway_ipv4"})
|
||||||
|
res.Attributes().SafeDelete([]string{"delete_default_routes_on_create"})
|
||||||
})
|
})
|
||||||
resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeNetworkResourceType, func(res *resource.Resource) map[string]string {
|
resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeNetworkResourceType, func(res *resource.Resource) map[string]string {
|
||||||
return map[string]string{
|
return map[string]string{
|
||||||
|
|
|
@ -15,6 +15,7 @@ func TestAcc_Google_ComputeNetwork(t *testing.T) {
|
||||||
"scan",
|
"scan",
|
||||||
"--to", "gcp+tf",
|
"--to", "gcp+tf",
|
||||||
"--filter", "Type=='google_compute_network'",
|
"--filter", "Type=='google_compute_network'",
|
||||||
|
"--deep",
|
||||||
},
|
},
|
||||||
Checks: []acceptance.AccCheck{
|
Checks: []acceptance.AccCheck{
|
||||||
{
|
{
|
||||||
|
@ -24,6 +25,7 @@ func TestAcc_Google_ComputeNetwork(t *testing.T) {
|
||||||
}
|
}
|
||||||
result.AssertInfrastructureIsInSync()
|
result.AssertInfrastructureIsInSync()
|
||||||
result.AssertManagedCount(3)
|
result.AssertManagedCount(3)
|
||||||
|
result.AssertDriftCountTotal(0)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue