From 3cf6d76bc988808b0394f931c14e1254bfdb5089 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Fri, 15 Dec 2023 17:23:21 -0500 Subject: [PATCH] fix syft-json test to use pretty json for snapshot testing (#2441) without this fix, capturing fixtures will result in hard-to-read failures in testing. Signed-off-by: Alex Goodman --- syft/format/syftjson/encoder_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/syft/format/syftjson/encoder_test.go b/syft/format/syftjson/encoder_test.go index f11a9e79af3..64346217395 100644 --- a/syft/format/syftjson/encoder_test.go +++ b/syft/format/syftjson/encoder_test.go @@ -297,10 +297,15 @@ func TestEncodeFullJSONDocument(t *testing.T) { }, } + cfg := DefaultEncoderConfig() + cfg.Pretty = true + enc, err := NewFormatEncoderWithConfig(cfg) + require.NoError(t, err) + testutil.AssertEncoderAgainstGoldenSnapshot(t, testutil.EncoderSnapshotTestConfig{ Subject: s, - Format: NewFormatEncoder(), + Format: enc, UpdateSnapshot: *updateSnapshot, PersistRedactionsInSnapshot: true, IsJSON: true,