mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Fix kyaml tests
This commit is contained in:
@@ -743,26 +743,6 @@ func TestFormatFileOrDirectory_ymlExtFile(t *testing.T) {
|
||||
assert.Equal(t, string(testyaml.FormattedYaml1), string(b))
|
||||
}
|
||||
|
||||
// TestFormatFileOrDirectory_skipYamlExtFileWithJson verifies that the json content is formatted
|
||||
// as yaml
|
||||
func TestFormatFileOrDirectory_YamlExtFileWithJson(t *testing.T) {
|
||||
// write the unformatted JSON file contents
|
||||
f, err := ioutil.TempFile("", "yamlfmt*.yaml")
|
||||
assert.NoError(t, err)
|
||||
defer os.Remove(f.Name())
|
||||
err = ioutil.WriteFile(f.Name(), testyaml.UnformattedJSON1, 0600)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// format the file
|
||||
err = FormatFileOrDirectory(f.Name())
|
||||
assert.NoError(t, err)
|
||||
|
||||
// check the result is formatted as yaml
|
||||
b, err := ioutil.ReadFile(f.Name())
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, string(testyaml.FormattedJSON1), string(b))
|
||||
}
|
||||
|
||||
// TestFormatFileOrDirectory_partialKubernetesYamlFile verifies that if a yaml file contains both
|
||||
// Kubernetes and non-Kubernetes documents, it will only format the Kubernetes documents
|
||||
func TestFormatFileOrDirectory_partialKubernetesYamlFile(t *testing.T) {
|
||||
|
||||
@@ -68,15 +68,6 @@ metadata:
|
||||
selfLink: ""
|
||||
`)
|
||||
|
||||
var UnformattedJSON1 = []byte(`
|
||||
{
|
||||
"spec": "a",
|
||||
"status": {"conditions": [3, 1, 2]},
|
||||
"apiVersion": "example.com/v1beta1",
|
||||
"kind": "MyType"
|
||||
}
|
||||
`)
|
||||
|
||||
var FormattedYaml1 = []byte(`apiVersion: example.com/v1beta1
|
||||
kind: MyType
|
||||
spec: a
|
||||
@@ -97,20 +88,6 @@ status2:
|
||||
- 2
|
||||
`)
|
||||
|
||||
var FormattedJSON1 = []byte(`{
|
||||
"apiVersion": "example.com/v1beta1",
|
||||
"kind": "MyType",
|
||||
"spec": "a",
|
||||
"status": {
|
||||
"conditions": [
|
||||
3,
|
||||
1,
|
||||
2
|
||||
]
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
var FormattedYaml3 = []byte(`apiVersion: v1
|
||||
kind: List
|
||||
metadata:
|
||||
|
||||
Reference in New Issue
Block a user