1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Fixed explode for aliases to scalars

This commit is contained in:
Mike Farah
2020-02-07 10:09:20 +11:00
parent 63313ebb02
commit d40ad9649d
2 changed files with 39 additions and 3 deletions

View File

@@ -307,6 +307,21 @@ foobar:
test.AssertResult(t, expectedOutput, result.Output)
}
func TestReadMergeAnchorsExplodeSimpleValueCmd(t *testing.T) {
content := `value: &value-pointer the value
pointer: *value-pointer`
filename := test.WriteTempYamlFile(content)
defer test.RemoveTempYamlFile(filename)
cmd := getRootCommand()
result := test.RunCmd(cmd, fmt.Sprintf("read -X %s pointer", filename))
if result.Error != nil {
t.Error(result.Error)
}
expectedOutput := `the value`
test.AssertResult(t, expectedOutput, result.Output)
}
func TestReadMergeAnchorsExplodeCmd(t *testing.T) {
cmd := getRootCommand()
result := test.RunCmd(cmd, "read -X ../examples/merge-anchor.yaml")
@@ -337,6 +352,21 @@ foobar:
test.AssertResult(t, expectedOutput, result.Output)
}
func TestReadMergeAnchorsExplodeDeepCmd(t *testing.T) {
cmd := getRootCommand()
result := test.RunCmd(cmd, "read -X ../examples/merge-anchor.yaml foobar")
if result.Error != nil {
t.Error(result.Error)
}
expectedOutput := `thirty: well beyond
thing: ice
c: 3
a: original
thirsty: yep
`
test.AssertResult(t, expectedOutput, result.Output)
}
func TestReadMergeAnchorsOverrideCmd(t *testing.T) {
cmd := getRootCommand()
result := test.RunCmd(cmd, "read ../examples/merge-anchor.yaml foobar.thing")