@@ -104,60 +104,6 @@ func TestInferValues(t *testing.T) {
104104 }
105105}
106106
107- func TestInferStructure (t * testing.T ) {
108- ds := & dataset.Dataset {
109- Name : "animals" ,
110- }
111- ds .SetBodyFile (qfs .NewMemfileBytes ("animals.csv" ,
112- []byte ("Animal,Sound,Weight\n cat,meow,1.4\n dog,bark,3.7\n " )))
113-
114- if err := InferStructure (ds ); err != nil {
115- t .Error (err )
116- }
117-
118- if ds .Structure .Format != "csv" {
119- t .Errorf ("expected format CSV, got %s" , ds .Structure .Format )
120- }
121- if ds .Structure .FormatConfig ["headerRow" ] != true {
122- t .Errorf ("expected format config to set headerRow set to true" )
123- }
124-
125- actual := datasetSchemaToJSON (ds )
126- expect := `{"items":{"items":[{"title":"animal","type":"string"},{"title":"sound","type":"string"},{"title":"weight","type":"number"}],"type":"array"},"type":"array"}`
127-
128- if expect != actual {
129- t .Errorf ("mismatched schema, expected \" %s\" , got \" %s\" " , expect , actual )
130- }
131- }
132-
133- func TestInferStructureSchema (t * testing.T ) {
134- ds := & dataset.Dataset {
135- Name : "animals" ,
136- Structure : & dataset.Structure {
137- Format : "csv" ,
138- },
139- }
140- ds .SetBodyFile (qfs .NewMemfileBytes ("animals.csv" ,
141- []byte ("Animal,Sound,Weight\n cat,meow,1.4\n dog,bark,3.7\n " )))
142- if err := InferStructure (ds ); err != nil {
143- t .Error (err )
144- }
145-
146- if ds .Structure .Format != "csv" {
147- t .Errorf ("expected format CSV, got %s" , ds .Structure .Format )
148- }
149- if ds .Structure .FormatConfig ["headerRow" ] != true {
150- t .Errorf ("expected format config to set headerRow set to true" )
151- }
152-
153- actual := datasetSchemaToJSON (ds )
154- expect := `{"items":{"items":[{"title":"animal","type":"string"},{"title":"sound","type":"string"},{"title":"weight","type":"number"}],"type":"array"},"type":"array"}`
155-
156- if expect != actual {
157- t .Errorf ("mismatched schema, expected \" %s\" , got \" %s\" " , expect , actual )
158- }
159- }
160-
161107func TestInferValuesDontOverwriteSchema (t * testing.T ) {
162108 r := newTestRepo (t )
163109 pro := r .Profiles ().Owner ()
@@ -188,15 +134,15 @@ func TestInferValuesDontOverwriteSchema(t *testing.T) {
188134 if ds .Structure .Format != "csv" {
189135 t .Errorf ("expected format CSV, got %s" , ds .Structure .Format )
190136 }
191- if ds .Structure .FormatConfig ! = nil {
192- t .Errorf ("expected format config to be nil" )
137+ if ds .Structure .FormatConfig = = nil {
138+ t .Errorf ("expected format config to be non- nil" )
193139 }
194140
195141 actual := datasetSchemaToJSON (ds )
196142 expect := `{"items":{"items":[{"title":"animal","type":"number"},{"title":"noise","type":"number"},{"title":"height","type":"number"}],"type":"array"},"type":"array"}`
197143
198144 if expect != actual {
199- t .Errorf ("mismatched schema, expected \" %s \" , got \" %s \" " , expect , actual )
145+ t .Errorf ("mismatched schema, expected %q , got %q " , expect , actual )
200146 }
201147}
202148
0 commit comments