batch_file_test.go 653 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
package safe

import (
	"bytes"
	"encoding/json"
	"os"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestBatchFileJSONPrepareBedrock(t *testing.T) {
	testBatchFileJSON(t, "testdata/batch-prepare-bedrock.json")
}

func TestBatchFileJSONL2OO(t *testing.T) {
	testBatchFileJSON(t, "testdata/l2-output-oracle.json")
}

func testBatchFileJSON(t *testing.T, path string) {
	b, err := os.ReadFile(path)
	require.NoError(t, err)
	dec := json.NewDecoder(bytes.NewReader(b))
	decoded := new(BatchFile)
	require.NoError(t, dec.Decode(decoded))
	data, err := json.Marshal(decoded)
	require.NoError(t, err)
	require.JSONEq(t, string(b), string(data))
}