driftctl/enumeration/remote/scanner_test.go

34 lines
924 B
Go
Raw Normal View History

2021-07-26 09:55:59 +00:00
package remote
import (
"testing"
"github.com/snyk/driftctl/enumeration"
"github.com/snyk/driftctl/enumeration/alerter"
common2 "github.com/snyk/driftctl/enumeration/remote/common"
"github.com/snyk/driftctl/enumeration/resource"
2021-07-26 09:55:59 +00:00
"github.com/stretchr/testify/assert"
)
func TestScannerShouldIgnoreType(t *testing.T) {
// Initialize mocks
alerter := alerter.NewAlerter()
fakeEnumerator := &common2.MockEnumerator{}
2021-07-26 09:55:59 +00:00
fakeEnumerator.On("SupportedType").Return(resource.ResourceType("FakeType"))
fakeEnumerator.AssertNotCalled(t, "Enumerate")
remoteLibrary := common2.NewRemoteLibrary()
2021-07-26 09:55:59 +00:00
remoteLibrary.AddEnumerator(fakeEnumerator)
testFilter := &enumeration.MockFilter{}
2021-07-26 09:55:59 +00:00
testFilter.On("IsTypeIgnored", resource.ResourceType("FakeType")).Return(true)
s := NewScanner(remoteLibrary, alerter, ScannerOptions{}, testFilter)
_, err := s.Resources()
assert.Nil(t, err)
fakeEnumerator.AssertExpectations(t)
}