From cc44e368b8822a2b4a10b5733c6fad713596cff0 Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Wed, 15 Jan 2025 09:46:06 +0100 Subject: [PATCH] Golden files: always include JSON-ed string (cont) (#2147) ## Changes Follow up to #2142 which did not actually enabled JSON conversion because of reversed condition on err. ## Tests Tested via #2118 --- libs/testdiff/golden.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/testdiff/golden.go b/libs/testdiff/golden.go index 78973b468..dd07df408 100644 --- a/libs/testdiff/golden.go +++ b/libs/testdiff/golden.go @@ -129,9 +129,9 @@ func (r *ReplacementsContext) Set(old, new string) { // In that case we cannot rely that json(old) == '"{old}"' and need to add it explicitly. encodedNew, err := json.Marshal(new) - if err != nil { + if err == nil { encodedOld, err := json.Marshal(old) - if err != nil { + if err == nil { r.Repls = append(r.Repls, Replacement{Old: string(encodedOld), New: string(encodedNew)}) } }