mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-07 02:48:27 +08:00
Allow build without json and xml support (#1556)
* Refactor ordered_map into separate files Separate json and xml, from the regular yaml. Makes it possible to compile, without those... * Refactor encoder and decoder creation Use more consistent parameters vs globals Return errors instead of calling panic() * Allow build without json and xml support
This commit is contained in:
@@ -28,6 +28,7 @@ type expressionScenario struct {
|
||||
skipDoc bool
|
||||
expectedError string
|
||||
dontFormatInputForDoc bool // dont format input doc for documentation generation
|
||||
requiresFormat string
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -103,6 +104,23 @@ func testScenario(t *testing.T, s *expressionScenario) {
|
||||
return
|
||||
}
|
||||
|
||||
if s.requiresFormat != "" {
|
||||
format := s.requiresFormat
|
||||
inputFormat, err := InputFormatFromString(format)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if decoder := createDecoder(inputFormat); decoder == nil {
|
||||
t.Skipf("no support for %s input format", format)
|
||||
}
|
||||
outputFormat, err := OutputFormatFromString(format)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if encoder := configureEncoder(outputFormat, 4); encoder == nil {
|
||||
t.Skipf("no support for %s output format", format)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
t.Error(fmt.Errorf("%w: %v: %v", err, s.description, s.expression))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user