test(analyser): enable slice ordering
parent
32daca00c4
commit
753dd50286
|
@ -83,28 +83,31 @@ func (a Analyzer) Analyze(remoteResources, resourcesFromState []resource.Resourc
|
|||
analysis.AddManaged(stateRes)
|
||||
|
||||
delta, _ := diff.Diff(stateRes, remoteRes)
|
||||
if len(delta) > 0 {
|
||||
sort.Slice(delta, func(i, j int) bool {
|
||||
return delta[i].Type < delta[j].Type
|
||||
|
||||
if len(delta) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
sort.Slice(delta, func(i, j int) bool {
|
||||
return delta[i].Type < delta[j].Type
|
||||
})
|
||||
changelog := make([]Change, 0, len(delta))
|
||||
for _, change := range delta {
|
||||
if filter.IsFieldIgnored(stateRes, change.Path) {
|
||||
continue
|
||||
}
|
||||
c := Change{Change: change}
|
||||
c.Computed = a.isComputedField(stateRes, c)
|
||||
if c.Computed {
|
||||
haveComputedDiff = true
|
||||
}
|
||||
changelog = append(changelog, c)
|
||||
}
|
||||
if len(changelog) > 0 {
|
||||
analysis.AddDifference(Difference{
|
||||
Res: stateRes,
|
||||
Changelog: changelog,
|
||||
})
|
||||
changelog := make([]Change, 0, len(delta))
|
||||
for _, change := range delta {
|
||||
if filter.IsFieldIgnored(stateRes, change.Path) {
|
||||
continue
|
||||
}
|
||||
c := Change{Change: change}
|
||||
c.Computed = a.isComputedField(stateRes, c)
|
||||
if c.Computed {
|
||||
haveComputedDiff = true
|
||||
}
|
||||
changelog = append(changelog, c)
|
||||
}
|
||||
if len(changelog) > 0 {
|
||||
analysis.AddDifference(Difference{
|
||||
Res: stateRes,
|
||||
Changelog: changelog,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -975,6 +975,11 @@ func TestAnalyze(t *testing.T) {
|
|||
t.Fatalf("Error creating new differ: %e", err)
|
||||
}
|
||||
|
||||
differ, err := diff.NewDiffer(diff.SliceOrdering(true))
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating new differ: %e", err)
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
filter := &mocks.Filter{}
|
||||
|
|
Loading…
Reference in New Issue