Skip to content

Commit a7d38b7

Browse files
committed
Update docs_test.go
1 parent 52e4d60 commit a7d38b7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

jsonschema/docs/docs_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package docs
22

33
import (
44
"embed"
5+
"encoding/json"
56
"strings"
67
"testing"
78

89
"github.com/bradleyjkemp/cupaloy/v2"
10+
"github.com/invopop/jsonschema"
911
"github.com/stretchr/testify/require"
1012
)
1113

@@ -29,22 +31,45 @@ func genSnapshot(t *testing.T, fileName string) {
2931
cupaloy.New(cupaloy.SnapshotFileExtension(".md")).SnapshotT(t, normalizeContent(doc))
3032
}
3133

34+
func genSnapshotStruct(t *testing.T, fileName string) {
35+
data, err := schemaFS.ReadFile(fileName)
36+
require.NoError(t, err)
37+
38+
var root jsonschema.Schema
39+
err = json.Unmarshal(data, &root)
40+
41+
require.NoError(t, err)
42+
43+
doc, err := GenerateFromSchema(root, 1)
44+
require.NoError(t, err)
45+
46+
cupaloy.New(cupaloy.SnapshotFileExtension(".md")).SnapshotT(t, normalizeContent(doc))
47+
}
48+
3249
func TestAWS(t *testing.T) {
3350
genSnapshot(t, "testdata/aws.json")
51+
genSnapshotStruct(t, "testdata/aws.json")
3452
}
3553

3654
func TestGCP(t *testing.T) {
3755
genSnapshot(t, "testdata/gcp.json")
56+
genSnapshotStruct(t, "testdata/gcp.json")
3857
}
3958

4059
func TestClickHouse(t *testing.T) {
4160
genSnapshot(t, "testdata/clickhouse.json")
61+
genSnapshot(t, "testdata/clickhouse.json")
62+
4263
}
4364

4465
func TestFiletypes(t *testing.T) {
4566
genSnapshot(t, "testdata/filetypes.json")
67+
genSnapshot(t, "testdata/filetypes.json")
68+
4669
}
4770

4871
func TestFileDestination(t *testing.T) {
4972
genSnapshot(t, "testdata/file-destination.json")
73+
genSnapshot(t, "testdata/file-destination.json")
74+
5075
}

0 commit comments

Comments
 (0)