Use the json schema as input for templating (#2542)

* use the json schema as input for templating

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* fix cli tests

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
Alex Goodman
2024-01-25 14:00:35 +00:00
committed by GitHub
parent 11c0b1c234
commit a32b8d7fc6
12 changed files with 100 additions and 13 deletions
+36 -1
View File
@@ -12,6 +12,42 @@ import (
var updateSnapshot = flag.Bool("update-template", false, "update the *.golden files for json encoders")
func TestFormatWithOption_Legacy(t *testing.T) {
f, err := NewFormatEncoder(EncoderConfig{
TemplatePath: "test-fixtures/legacy/csv.template",
Legacy: true,
})
require.NoError(t, err)
testutil.AssertEncoderAgainstGoldenSnapshot(t,
testutil.EncoderSnapshotTestConfig{
Subject: testutil.DirectoryInput(t, t.TempDir()),
Format: f,
UpdateSnapshot: *updateSnapshot,
PersistRedactionsInSnapshot: true,
IsJSON: false,
},
)
}
func TestFormatWithOptionAndHasField_Legacy(t *testing.T) {
f, err := NewFormatEncoder(EncoderConfig{
TemplatePath: "test-fixtures/legacy/csv-hasField.template",
Legacy: true,
})
require.NoError(t, err)
testutil.AssertEncoderAgainstGoldenSnapshot(t,
testutil.EncoderSnapshotTestConfig{
Subject: testutil.DirectoryInputWithAuthorField(t),
Format: f,
UpdateSnapshot: *updateSnapshot,
PersistRedactionsInSnapshot: true,
IsJSON: false,
},
)
}
func TestFormatWithOption(t *testing.T) {
f, err := NewFormatEncoder(EncoderConfig{
TemplatePath: "test-fixtures/csv.template",
@@ -44,7 +80,6 @@ func TestFormatWithOptionAndHasField(t *testing.T) {
IsJSON: false,
},
)
}
func TestFormatWithoutOptions(t *testing.T) {