@@ -326,8 +326,9 @@ func documentUnwrappedEncodePropertyScenario(w *bufio.Writer, s formatScenario)
326
326
writeOrPanic (w , fmt .Sprintf ("```bash\n yq -o=props%v%v sample.yml\n ```\n " , useArrayBracketsFlag , useCustomSeparatorFlag ))
327
327
}
328
328
writeOrPanic (w , "will output\n " )
329
+ prefs .UnwrapScalar = true
329
330
330
- writeOrPanic (w , fmt .Sprintf ("```properties\n %v```\n \n " , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (true , prefs ))))
331
+ writeOrPanic (w , fmt .Sprintf ("```properties\n %v```\n \n " , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (prefs ))))
331
332
}
332
333
333
334
func documentWrappedEncodePropertyScenario (w * bufio.Writer , s formatScenario ) {
@@ -351,8 +352,9 @@ func documentWrappedEncodePropertyScenario(w *bufio.Writer, s formatScenario) {
351
352
writeOrPanic (w , "```bash\n yq -o=props --unwrapScalar=false sample.yml\n ```\n " )
352
353
}
353
354
writeOrPanic (w , "will output\n " )
354
-
355
- writeOrPanic (w , fmt .Sprintf ("```properties\n %v```\n \n " , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (false , ConfiguredPropertiesPreferences ))))
355
+ prefs := ConfiguredPropertiesPreferences .Copy ()
356
+ prefs .UnwrapScalar = false
357
+ writeOrPanic (w , fmt .Sprintf ("```properties\n %v```\n \n " , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (prefs ))))
356
358
}
357
359
358
360
func documentDecodePropertyScenario (w * bufio.Writer , s formatScenario ) {
@@ -402,7 +404,7 @@ func documentRoundTripPropertyScenario(w *bufio.Writer, s formatScenario) {
402
404
403
405
writeOrPanic (w , "will output\n " )
404
406
405
- writeOrPanic (w , fmt .Sprintf ("```properties\n %v```\n \n " , mustProcessFormatScenario (s , NewPropertiesDecoder (), NewPropertiesEncoder (true , ConfiguredPropertiesPreferences ))))
407
+ writeOrPanic (w , fmt .Sprintf ("```properties\n %v```\n \n " , mustProcessFormatScenario (s , NewPropertiesDecoder (), NewPropertiesEncoder (ConfiguredPropertiesPreferences ))))
406
408
}
407
409
408
410
func documentPropertyScenario (_ * testing.T , w * bufio.Writer , i interface {}) {
@@ -429,17 +431,24 @@ func TestPropertyScenarios(t *testing.T) {
429
431
for _ , s := range propertyScenarios {
430
432
switch s .scenarioType {
431
433
case "" :
432
- test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (true , ConfiguredPropertiesPreferences )), s .description )
434
+ test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (ConfiguredPropertiesPreferences )), s .description )
433
435
case "decode" :
434
436
test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewPropertiesDecoder (), NewYamlEncoder (2 , false , ConfiguredYamlPreferences )), s .description )
435
437
case "encode-wrapped" :
436
- test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (false , ConfiguredPropertiesPreferences )), s .description )
438
+ prefs := ConfiguredPropertiesPreferences .Copy ()
439
+ prefs .UnwrapScalar = false
440
+ test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (prefs )), s .description )
437
441
case "encode-array-brackets" :
438
- test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (true , PropertiesPreferences {KeyValueSeparator : " = " , UseArrayBrackets : true })), s .description )
442
+ prefs := ConfiguredPropertiesPreferences .Copy ()
443
+ prefs .KeyValueSeparator = " = "
444
+ prefs .UseArrayBrackets = true
445
+ test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (prefs )), s .description )
439
446
case "encode-custom-separator" :
440
- test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (true , PropertiesPreferences {KeyValueSeparator : " :@ " })), s .description )
447
+ prefs := ConfiguredPropertiesPreferences .Copy ()
448
+ prefs .KeyValueSeparator = " :@ "
449
+ test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewYamlDecoder (ConfiguredYamlPreferences ), NewPropertiesEncoder (prefs )), s .description )
441
450
case "roundtrip" :
442
- test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewPropertiesDecoder (), NewPropertiesEncoder (true , ConfiguredPropertiesPreferences )), s .description )
451
+ test .AssertResultWithContext (t , s .expected , mustProcessFormatScenario (s , NewPropertiesDecoder (), NewPropertiesEncoder (ConfiguredPropertiesPreferences )), s .description )
443
452
444
453
default :
445
454
panic (fmt .Sprintf ("unhandled scenario type %q" , s .scenarioType ))
0 commit comments