File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
internal/testrunner/runners/pipeline Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -146,13 +146,29 @@ func unmarshalTestResult(body []byte) (*testResult, error) {
146146func marshalTestResultDefinition (result * testResult ) ([]byte , error ) {
147147 var trd testResultDefinition
148148 trd .Expected = result .events
149- body , err := json . MarshalIndent ( & trd , "" , " " )
149+ body , err := marshalNormalizedJSON ( trd )
150150 if err != nil {
151151 return nil , errors .Wrap (err , "marshalling test result definition failed" )
152152 }
153153 return body , nil
154154}
155155
156+ // marshalNormalizedJSON marshals test results ensuring that field
157+ // order remains consistent independent of field order returned by
158+ // ES to minimize diff noise during changes.
159+ func marshalNormalizedJSON (v testResultDefinition ) ([]byte , error ) {
160+ msg , err := json .Marshal (v )
161+ if err != nil {
162+ return msg , err
163+ }
164+ var obj interface {}
165+ err = json .Unmarshal (msg , & obj )
166+ if err != nil {
167+ return msg , err
168+ }
169+ return json .MarshalIndent (obj , "" , " " )
170+ }
171+
156172func expectedTestResultFile (testFile string ) string {
157173 return fmt .Sprintf ("%s%s" , testFile , expectedTestResultSuffix )
158174}
You can’t perform that action at this time.
0 commit comments