Introduce NewAnalysis(), use it in analyzer, update fakeAnalyzer accordingly
parent
7476cfa081
commit
972eddcd79
|
@ -73,6 +73,10 @@ type GenDriftIgnoreOptions struct {
|
|||
OutputPath string
|
||||
}
|
||||
|
||||
func NewAnalysis(options AnalyzerOptions) Analysis {
|
||||
return Analysis{options: options}
|
||||
}
|
||||
|
||||
func (a Analysis) MarshalJSON() ([]byte, error) {
|
||||
bla := serializableAnalysis{}
|
||||
for _, m := range a.managed {
|
||||
|
|
|
@ -31,7 +31,7 @@ func TestConsole_Write(t *testing.T) {
|
|||
name: "test console output",
|
||||
goldenfile: "output.txt",
|
||||
args: args{analysis: func() *analyser.Analysis {
|
||||
a := fakeAnalysis()
|
||||
a := fakeAnalysis(analyser.AnalyzerOptions{})
|
||||
a.AddDeleted(
|
||||
&resource.Resource{
|
||||
Id: "test-id-1",
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestJSON_Write(t *testing.T) {
|
|||
name: "test json output",
|
||||
goldenfile: "output.json",
|
||||
args: args{
|
||||
analysis: fakeAnalysis(),
|
||||
analysis: fakeAnalysis(analyser.AnalyzerOptions{}),
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
|
@ -103,7 +103,7 @@ func TestJSON_Write_stdout(t *testing.T) {
|
|||
goldenfile: "output.json",
|
||||
path: "stdout",
|
||||
args: args{
|
||||
analysis: fakeAnalysis(),
|
||||
analysis: fakeAnalysis(analyser.AnalyzerOptions{}),
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
|
@ -113,7 +113,7 @@ func TestJSON_Write_stdout(t *testing.T) {
|
|||
goldenfile: "output.json",
|
||||
path: "/dev/stdout",
|
||||
args: args{
|
||||
analysis: fakeAnalysis(),
|
||||
analysis: fakeAnalysis(analyser.AnalyzerOptions{}),
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
|
@ -160,7 +160,7 @@ func TestJSON_Write_stdout(t *testing.T) {
|
|||
|
||||
func TestJSON_WriteMultiplesTimesInSameFile(t *testing.T) {
|
||||
emptyAnalysis := &analyser.Analysis{}
|
||||
longerAnalysis := fakeAnalysis()
|
||||
longerAnalysis := fakeAnalysis(analyser.AnalyzerOptions{})
|
||||
tempDir := t.TempDir()
|
||||
tempFile, err := ioutil.TempFile(tempDir, "result")
|
||||
if err != nil {
|
||||
|
|
|
@ -16,8 +16,8 @@ import (
|
|||
"github.com/r3labs/diff/v2"
|
||||
)
|
||||
|
||||
func fakeAnalysis() *analyser.Analysis {
|
||||
a := analyser.Analysis{}
|
||||
func fakeAnalysis(opts analyser.AnalyzerOptions) *analyser.Analysis {
|
||||
a := analyser.NewAnalysis(opts)
|
||||
a.AddUnmanaged(
|
||||
&resource.Resource{
|
||||
Id: "unmanaged-id-1",
|
||||
|
@ -110,7 +110,7 @@ func fakeAnalysis() *analyser.Analysis {
|
|||
}
|
||||
|
||||
func fakeAnalysisWithAlerts() *analyser.Analysis {
|
||||
a := fakeAnalysis()
|
||||
a := fakeAnalysis(analyser.AnalyzerOptions{})
|
||||
a.SetAlerts(alerter.Alerts{
|
||||
"": []alerter.Alert{
|
||||
alerts.NewRemoteAccessDeniedAlert(common.RemoteAWSTerraform, remoteerr.NewResourceListingErrorWithType(errors.New("dummy error"), "aws_vpc", "aws_vpc"), alerts.EnumerationPhase),
|
||||
|
|
Loading…
Reference in New Issue