From ee07edbd88b455d450052dbbac7f31dedc039e86 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Thu, 18 Jun 2020 09:56:36 +1000 Subject: [PATCH] Added merge alias test --- cmd/merge_test.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/cmd/merge_test.go b/cmd/merge_test.go index 458ec8b9..f9718b0d 100644 --- a/cmd/merge_test.go +++ b/cmd/merge_test.go @@ -109,6 +109,49 @@ func TestMergeAppendArraysCmd(t *testing.T) { test.AssertResult(t, expectedOutput, result.Output) } +func TestMergeAliasArraysCmd(t *testing.T) { + content := ` +vars: + variable1: &var1 cat + +usage: + value1: *var1 + valueAnother: *var1 + valuePlain: thing +` + filename := test.WriteTempYamlFile(content) + defer test.RemoveTempYamlFile(filename) + + mergeContent := ` +vars: + variable2: &var2 puppy + +usage: + value2: *var2 + valueAnother: *var2 + valuePlain: *var2 +` + + mergeFilename := test.WriteTempYamlFile(mergeContent) + defer test.RemoveTempYamlFile(mergeFilename) + + cmd := getRootCommand() + result := test.RunCmd(cmd, fmt.Sprintf("merge -x %s %s", filename, mergeFilename)) + if result.Error != nil { + t.Error(result.Error) + } + expectedOutput := `vars: + variable1: &var1 cat + variable2: &var2 puppy +usage: + value1: *var1 + valueAnother: *var2 + valuePlain: *var2 + value2: *var2 +` + test.AssertResult(t, expectedOutput, result.Output) +} + func TestMergeOverwriteAndAppendCmd(t *testing.T) { cmd := getRootCommand() result := test.RunCmd(cmd, "merge --autocreate=false --append --overwrite ../examples/data1.yaml ../examples/data2.yaml")