diff --git a/cmd/config/internal/commands/cmdlistsetters_test.go b/cmd/config/internal/commands/cmdlistsetters_test.go index b397854a9..cd684fbbb 100644 --- a/cmd/config/internal/commands/cmdlistsetters_test.go +++ b/cmd/config/internal/commands/cmdlistsetters_test.go @@ -7,6 +7,7 @@ import ( "bytes" "io/ioutil" "os" + "strings" "testing" "github.com/stretchr/testify/assert" @@ -49,6 +50,32 @@ spec: replicas 3 me hello world 1 Yes `, }, + + { + name: "list-replicas inconsistent with openapi", + openapi: ` +openAPI: + definitions: + io.k8s.cli.setters.replicas: + x-k8s-cli: + setter: + name: replicas + value: "4" + setBy: me + description: "hello world" + `, + input: ` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + replicas: 3 # {"$ref": "#/definitions/io.k8s.cli.setters.replicas"} + `, + expected: ` NAME VALUE SET BY DESCRIPTION COUNT + replicas 4 me hello world 1 +`, + }, { name: "list-multiple", openapi: ` @@ -414,6 +441,27 @@ openAPI: if !assert.Equal(t, test.expected, actual.String()) { t.FailNow() } + + // make sure that the resources are not altered + actualResources, err := ioutil.ReadFile(r.Name()) + if !assert.NoError(t, err) { + t.FailNow() + } + if !assert.Equal(t, + strings.TrimSpace(test.input), + strings.TrimSpace(string(actualResources))) { + t.FailNow() + } + + actualOpenAPI, err := ioutil.ReadFile(f.Name()) + if !assert.NoError(t, err) { + t.FailNow() + } + if !assert.Equal(t, + strings.TrimSpace(test.openapi), + strings.TrimSpace(string(actualOpenAPI))) { + t.FailNow() + } }) } }