Fix kyaml tests

This commit is contained in:
Mattias Öhrn
2021-06-03 08:31:03 +02:00
parent 03bbb076bf
commit 942f112ef5
3 changed files with 3 additions and 46 deletions

View File

@@ -194,7 +194,7 @@ metadata:
// Test Case
//
{
name: "encode_valid_json",
name: "encode_valid_json",
items: []string{
`{
"a": "a long string that would certainly see a newline introduced by the YAML marshaller abcd123",
@@ -220,7 +220,7 @@ metadata:
// Test Case
//
{
name: "encode_wrapped_json_as_yaml",
name: "encode_wrapped_json_as_yaml",
instance: ByteWriter{
Sort: true,
WrappingKind: ResourceListKind,
@@ -248,7 +248,7 @@ items:
// Test Case
//
{
name: "encode_multi_doc_json_as_yaml",
name: "encode_multi_doc_json_as_yaml",
items: []string{
`{
"a": "b",

View File

@@ -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) {

View File

@@ -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: