@@ -68,6 +68,40 @@ func (s *Suite) TestValidCases() {
68
68
}
69
69
}
70
70
71
+ func (s * Suite ) TestValidateBytes () {
72
+ cases := []string {
73
+ "v1.0.0-beta.2/LC08_L1TP_097073_20130319_20200913_02_T1.json" ,
74
+ "v1.0.0/catalog.json" ,
75
+ "v1.0.0/collection.json" ,
76
+ "v1.0.0/item.json" ,
77
+ "v1.0.0/catalog-with-item.json" ,
78
+ "v1.0.0/catalog-with-multiple-items.json" ,
79
+ "v1.0.0/item-eo.json" ,
80
+ }
81
+
82
+ ctx := context .Background ()
83
+ for _ , c := range cases {
84
+ s .Run (c , func () {
85
+ location := path .Join ("testdata" , "cases" , c )
86
+ data , err := os .ReadFile (location )
87
+ s .Require ().NoError (err )
88
+ s .NoError (validator .ValidateBytes (ctx , data , location ))
89
+ })
90
+ }
91
+ }
92
+
93
+ func (s * Suite ) TestValidateBytesInvalidItem () {
94
+ location := "testdata/cases/v1.0.0/item-missing-id.json"
95
+
96
+ data , readErr := os .ReadFile (location )
97
+ s .Require ().NoError (readErr )
98
+ ctx := context .Background ()
99
+
100
+ err := validator .ValidateBytes (ctx , data , location )
101
+ s .Require ().Error (err )
102
+ s .Assert ().True (strings .HasSuffix (fmt .Sprintf ("%#v" , err ), "missing properties: 'id'" ))
103
+ }
104
+
71
105
func (s * Suite ) TestSchemaMap () {
72
106
v := validator .New (& validator.Options {
73
107
SchemaMap : map [string ]string {
0 commit comments