Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattias Öhrn committed Jun 3, 2021
1 parent 5e4fb47 commit 95e8ec5
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 49 deletions.
14 changes: 12 additions & 2 deletions cmd/config/internal/commands/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,18 @@ metadata:
expectedFiles: func(d string) map[string]string {
return map[string]string{
"deployment.json": `
{"apiVersion": "apps/v1", "kind": "Deployment", "metadata": {"name": "foo", annotations: {
a-string-value: '', a-int-value: '0', a-bool-value: 'false'}}}
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"a-bool-value": "false",
"a-int-value": "0",
"a-string-value": ""
},
"name": "foo"
}
}
`,
}
},
Expand Down
6 changes: 3 additions & 3 deletions kyaml/kio/byteio_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
20 changes: 0 additions & 20 deletions kyaml/kio/filters/fmtr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
23 changes: 0 additions & 23 deletions kyaml/kio/filters/testyaml/testyaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion plugin/builtin/iampolicygenerator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
Expand Down

0 comments on commit 95e8ec5

Please sign in to comment.