|
|
|
@ -32,7 +32,8 @@ type TestCase struct {
|
|
|
|
|
stateResources []resource.Resource
|
|
|
|
|
remoteResources []resource.Resource
|
|
|
|
|
mocks func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface)
|
|
|
|
|
assert func(t *testing.T, result *test.ScanResult, err error, store memstore.Store)
|
|
|
|
|
assert func(t *testing.T, result *test.ScanResult, err error)
|
|
|
|
|
assertStore func(*testing.T, memstore.Store)
|
|
|
|
|
options *pkg.ScanOptions
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -105,7 +106,10 @@ func runTest(t *testing.T, cases TestCases) {
|
|
|
|
|
|
|
|
|
|
analysis, err := driftctl.Run()
|
|
|
|
|
|
|
|
|
|
c.assert(t, test.NewScanResult(t, analysis), err, store)
|
|
|
|
|
c.assert(t, test.NewScanResult(t, analysis), err)
|
|
|
|
|
if c.assertStore != nil {
|
|
|
|
|
c.assertStore(t, store)
|
|
|
|
|
}
|
|
|
|
|
scanProgress.AssertExpectations(t)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -127,12 +131,10 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
name: "analysis duration is set",
|
|
|
|
|
stateResources: []resource.Resource{},
|
|
|
|
|
remoteResources: []resource.Resource{},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.NotZero(result.Duration)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 0, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 0, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -146,12 +148,10 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
remoteResources: []resource.Resource{
|
|
|
|
|
&testresource.FakeResource{},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertInfrastructureIsInSync()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -166,12 +166,10 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
&testresource.FakeResource{},
|
|
|
|
|
},
|
|
|
|
|
remoteResources: []resource.Resource{},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertDeletedCount(1)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 0, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -183,12 +181,10 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
remoteResources: []resource.Resource{
|
|
|
|
|
&testresource.FakeResource{},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertUnmanagedCount(1)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 0, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -212,7 +208,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(1)
|
|
|
|
|
result.AssertResourceHasDrift("fake", "FakeResource", analyser.Change{
|
|
|
|
|
Change: diff.Change{
|
|
|
|
@ -223,10 +219,8 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
Computed: false,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -252,7 +246,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(1)
|
|
|
|
|
result.AssertResourceHasDrift("fake", aws.AwsAmiResourceType, analyser.Change{
|
|
|
|
|
Change: diff.Change{
|
|
|
|
@ -263,10 +257,8 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
Computed: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -292,7 +284,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(1)
|
|
|
|
|
result.AssertResourceHasDrift("fake", "FakeResource", analyser.Change{
|
|
|
|
|
Change: diff.Change{
|
|
|
|
@ -303,10 +295,8 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
Computed: false,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -332,7 +322,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(1)
|
|
|
|
|
result.AssertResourceHasDrift("fake", "FakeResource", analyser.Change{
|
|
|
|
|
Change: diff.Change{
|
|
|
|
@ -343,10 +333,8 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
Computed: false,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -428,15 +416,13 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(2)
|
|
|
|
|
result.AssertUnmanagedCount(2)
|
|
|
|
|
result.AssertDeletedCount(0)
|
|
|
|
|
result.AssertDriftCountTotal(0)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 4, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 2, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -524,15 +510,13 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(2)
|
|
|
|
|
result.AssertUnmanagedCount(4)
|
|
|
|
|
result.AssertDeletedCount(0)
|
|
|
|
|
result.AssertDriftCountTotal(0)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 6, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 2, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -620,17 +604,15 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertCoverage(0)
|
|
|
|
|
result.AssertInfrastructureIsNotSync()
|
|
|
|
|
result.AssertManagedCount(0)
|
|
|
|
|
result.AssertUnmanagedCount(1)
|
|
|
|
|
result.AssertDeletedCount(0)
|
|
|
|
|
result.AssertDriftCountTotal(0)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
},
|
|
|
|
|
assertStore: func(t *testing.T, store memstore.Store) {
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 0, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
@ -671,16 +653,9 @@ func TestDriftctlRun_BasicFilter(t *testing.T) {
|
|
|
|
|
Attrs: &resource.Attributes{},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertUnmanagedCount(1)
|
|
|
|
|
result.AssertResourceUnmanaged("res2", "filtered")
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 0, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Type=='filtered'"
|
|
|
|
@ -707,16 +682,9 @@ func TestDriftctlRun_BasicFilter(t *testing.T) {
|
|
|
|
|
Attrs: &resource.Attributes{},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertUnmanagedCount(1)
|
|
|
|
|
result.AssertResourceUnmanaged("res2", "filtered")
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 0, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Id=='res2'"
|
|
|
|
@ -745,16 +713,9 @@ func TestDriftctlRun_BasicFilter(t *testing.T) {
|
|
|
|
|
Attrs: &resource.Attributes{},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertUnmanagedCount(1)
|
|
|
|
|
result.AssertResourceUnmanaged("res1", "filtered")
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 0, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Attr.test_field=='value to filter on'"
|
|
|
|
@ -817,7 +778,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
Sch: getSchema(repo, aws.AwsS3BucketPolicyResourceType),
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(1)
|
|
|
|
|
result.AssertResourceHasDrift("foo", "aws_s3_bucket_policy", analyser.Change{
|
|
|
|
|
Change: diff.Change{
|
|
|
|
@ -829,13 +790,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
Computed: false,
|
|
|
|
|
JsonString: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Type=='aws_s3_bucket_policy' && Attr.bucket=='foo'"
|
|
|
|
@ -929,7 +883,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
})).Times(1).Return(&bar, nil)
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(2)
|
|
|
|
|
result.AssertResourceHasDrift("vol-02862d9b39045a3a4", "aws_ebs_volume", analyser.Change{
|
|
|
|
|
Change: diff.Change{
|
|
|
|
@ -949,13 +903,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
Computed: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 2, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 2, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Type=='aws_ebs_volume' && Attr.availability_zone=='us-east-1'"
|
|
|
|
@ -1052,16 +999,9 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
}, nil)
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(2)
|
|
|
|
|
result.AssertInfrastructureIsInSync()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 2, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 2, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Type=='aws_route' && Attr.gateway_id=='igw-07b7844a8fd17a638'"
|
|
|
|
@ -1113,7 +1053,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
Sch: getSchema(repo, aws.AwsSnsTopicPolicyResourceType),
|
|
|
|
|
}, nil)
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(1)
|
|
|
|
|
result.AssertResourceHasDrift("foo", "aws_sns_topic_policy", analyser.Change{
|
|
|
|
|
Change: diff.Change{
|
|
|
|
@ -1125,13 +1065,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
Computed: false,
|
|
|
|
|
JsonString: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Type=='aws_sns_topic_policy' && Attr.arn=='arn'"
|
|
|
|
@ -1182,7 +1115,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
Sch: getSchema(repo, aws.AwsSqsQueuePolicyResourceType),
|
|
|
|
|
}, nil)
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(1)
|
|
|
|
|
result.AssertResourceHasDrift("foo", "aws_sqs_queue_policy", analyser.Change{
|
|
|
|
|
Change: diff.Change{
|
|
|
|
@ -1194,13 +1127,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
Computed: false,
|
|
|
|
|
JsonString: true,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 1, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Type=='aws_sqs_queue_policy' && Attr.queue_url=='foo'"
|
|
|
|
@ -1514,16 +1440,9 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
})).Times(1).Return(&rule4, nil)
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(7)
|
|
|
|
|
result.AssertInfrastructureIsInSync()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 7, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 7, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Type=='aws_security_group_rule' && Attr.security_group_id=='sg-0254c038e32f25530'"
|
|
|
|
@ -1659,16 +1578,9 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
}, nil)
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertManagedCount(2)
|
|
|
|
|
result.AssertInfrastructureIsInSync()
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 2, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 2, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
options: func(t *testing.T) *pkg.ScanOptions {
|
|
|
|
|
filterStr := "Type=='aws_iam_policy_attachment'"
|
|
|
|
@ -1750,16 +1662,9 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
Attrs: &resource.Attributes{},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertInfrastructureIsInSync()
|
|
|
|
|
result.AssertManagedCount(5)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 5, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 5, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
@ -1836,16 +1741,9 @@ func TestDriftctlRun_Middlewares(t *testing.T) {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error, store memstore.Store) {
|
|
|
|
|
assert: func(t *testing.T, result *test.ScanResult, err error) {
|
|
|
|
|
result.AssertInfrastructureIsInSync()
|
|
|
|
|
result.AssertManagedCount(5)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "dev-dev", store.Bucket(memstore.TelemetryBucket).Get("version"))
|
|
|
|
|
assert.Equal(t, "linux", store.Bucket(memstore.TelemetryBucket).Get("os"))
|
|
|
|
|
assert.Equal(t, "amd64", store.Bucket(memstore.TelemetryBucket).Get("arch"))
|
|
|
|
|
assert.Equal(t, 5, store.Bucket(memstore.TelemetryBucket).Get("total_resources"))
|
|
|
|
|
assert.Equal(t, 5, store.Bucket(memstore.TelemetryBucket).Get("total_managed"))
|
|
|
|
|
assert.Equal(t, uint(0), store.Bucket(memstore.TelemetryBucket).Get("duration"))
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|