yq/cmd/compare_test.go

116 lines
3.0 KiB
Go
Raw Normal View History

package cmd
2020-10-13 01:51:37 +00:00
// import (
// "testing"
2020-10-13 01:51:37 +00:00
// "github.com/mikefarah/yq/v3/test"
// )
2020-10-13 01:51:37 +00:00
// func TestCompareSameCmd(t *testing.T) {
// cmd := getRootCommand()
// result := test.RunCmd(cmd, "compare ../examples/data1.yaml ../examples/data1.yaml")
// if result.Error != nil {
// t.Error(result.Error)
// }
// expectedOutput := ``
// test.AssertResult(t, expectedOutput, result.Output)
// }
2020-10-13 01:51:37 +00:00
// func TestCompareIgnoreCommentsCmd(t *testing.T) {
// cmd := getRootCommand()
// result := test.RunCmd(cmd, "compare --stripComments ../examples/data1.yaml ../examples/data1-no-comments.yaml")
// if result.Error != nil {
// t.Error(result.Error)
// }
// expectedOutput := ``
// test.AssertResult(t, expectedOutput, result.Output)
// }
2020-10-13 01:51:37 +00:00
// func TestCompareDontIgnoreCommentsCmd(t *testing.T) {
// forceOsExit = false
// cmd := getRootCommand()
// result := test.RunCmd(cmd, "compare ../examples/data1.yaml ../examples/data1-no-comments.yaml")
2020-10-13 01:51:37 +00:00
// expectedOutput := `-a: simple # just the best
// +a: simple
// b: [1, 2]
// c:
// test: 1
// `
// test.AssertResult(t, expectedOutput, result.Output)
// }
2020-10-13 01:51:37 +00:00
// func TestCompareExplodeAnchorsCommentsCmd(t *testing.T) {
// cmd := getRootCommand()
// result := test.RunCmd(cmd, "compare --explodeAnchors ../examples/simple-anchor.yaml ../examples/simple-anchor-exploded.yaml")
// if result.Error != nil {
// t.Error(result.Error)
// }
// expectedOutput := ``
// test.AssertResult(t, expectedOutput, result.Output)
// }
2020-10-13 01:51:37 +00:00
// func TestCompareDontExplodeAnchorsCmd(t *testing.T) {
// forceOsExit = false
// cmd := getRootCommand()
// result := test.RunCmd(cmd, "compare ../examples/simple-anchor.yaml ../examples/simple-anchor-exploded.yaml")
2020-10-13 01:51:37 +00:00
// expectedOutput := `-foo: &foo
// +foo:
// a: 1
// foobar:
// - !!merge <<: *foo
// + a: 1
// `
// test.AssertResult(t, expectedOutput, result.Output)
// }
2020-10-13 01:51:37 +00:00
// func TestCompareDifferentCmd(t *testing.T) {
// forceOsExit = false
// cmd := getRootCommand()
// result := test.RunCmd(cmd, "compare ../examples/data1.yaml ../examples/data3.yaml")
2020-10-13 01:51:37 +00:00
// expectedOutput := `-a: simple # just the best
// -b: [1, 2]
// +a: "simple" # just the best
// +b: [1, 3]
// c:
// test: 1
// `
// test.AssertResult(t, expectedOutput, result.Output)
// }
2020-10-13 01:51:37 +00:00
// func TestComparePrettyCmd(t *testing.T) {
// forceOsExit = false
// cmd := getRootCommand()
// result := test.RunCmd(cmd, "compare -P ../examples/data1.yaml ../examples/data3.yaml")
// if result.Error != nil {
// t.Error(result.Error)
// }
// expectedOutput := ` a: simple # just the best
// b:
// - 1
// - - 2
// + - 3
// c:
// test: 1
// `
// test.AssertResult(t, expectedOutput, result.Output)
// }
2020-10-13 01:51:37 +00:00
// func TestComparePathsCmd(t *testing.T) {
// forceOsExit = false
// cmd := getRootCommand()
// result := test.RunCmd(cmd, "compare -P -ppv ../examples/data1.yaml ../examples/data3.yaml **")
// if result.Error != nil {
// t.Error(result.Error)
// }
// expectedOutput := ` a: simple # just the best
// b.[0]: 1
// -b.[1]: 2
// +b.[1]: 3
// c.test: 1
// `
// test.AssertResult(t, expectedOutput, result.Output)
// }