mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
helper/schema: sort errors in helper/schema test for deterministic tests
This commit is contained in:
parent
43dcc30ae8
commit
b7bee66df5
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -3978,6 +3979,9 @@ func TestSchemaMap_Validate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tc.Errors != nil {
|
if tc.Errors != nil {
|
||||||
|
sort.Sort(errorSort(es))
|
||||||
|
sort.Sort(errorSort(tc.Errors))
|
||||||
|
|
||||||
if !reflect.DeepEqual(es, tc.Errors) {
|
if !reflect.DeepEqual(es, tc.Errors) {
|
||||||
t.Fatalf("%q: errors:\n\nexpected: %q\ngot: %q", tn, tc.Errors, es)
|
t.Fatalf("%q: errors:\n\nexpected: %q\ngot: %q", tn, tc.Errors, es)
|
||||||
}
|
}
|
||||||
@ -4166,3 +4170,12 @@ func TestSchemaSet_ValidateMinItems(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// errorSort implements sort.Interface to sort errors by their error message
|
||||||
|
type errorSort []error
|
||||||
|
|
||||||
|
func (e errorSort) Len() int { return len(e) }
|
||||||
|
func (e errorSort) Swap(i, j int) { e[i], e[j] = e[j], e[i] }
|
||||||
|
func (e errorSort) Less(i, j int) bool {
|
||||||
|
return e[i].Error() < e[j].Error()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user