Added a test for proper %s
handling when display last applied configuration
This commit is contained in:
@@ -63,15 +63,17 @@ func validateApplyArgs(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
filenameRC = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc.yaml"
|
filenameRC = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc.yaml"
|
||||||
filenameRCNoAnnotation = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-no-annotation.yaml"
|
filenameRCArgs = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-args.yaml"
|
||||||
filenameRCLASTAPPLIED = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-lastapplied.yaml"
|
filenameRCLastAppliedArgs = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-lastapplied-args.yaml"
|
||||||
filenameSVC = "../../../test/fixtures/pkg/kubectl/cmd/apply/service.yaml"
|
filenameRCNoAnnotation = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-no-annotation.yaml"
|
||||||
filenameRCSVC = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-service.yaml"
|
filenameRCLASTAPPLIED = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-lastapplied.yaml"
|
||||||
filenameNoExistRC = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-noexist.yaml"
|
filenameSVC = "../../../test/fixtures/pkg/kubectl/cmd/apply/service.yaml"
|
||||||
filenameRCPatchTest = "../../../test/fixtures/pkg/kubectl/cmd/apply/patch.json"
|
filenameRCSVC = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-service.yaml"
|
||||||
dirName = "../../../test/fixtures/pkg/kubectl/cmd/apply/testdir"
|
filenameNoExistRC = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc-noexist.yaml"
|
||||||
filenameRCJSON = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc.json"
|
filenameRCPatchTest = "../../../test/fixtures/pkg/kubectl/cmd/apply/patch.json"
|
||||||
|
dirName = "../../../test/fixtures/pkg/kubectl/cmd/apply/testdir"
|
||||||
|
filenameRCJSON = "../../../test/fixtures/pkg/kubectl/cmd/apply/rc.json"
|
||||||
|
|
||||||
filenameWidgetClientside = "../../../test/fixtures/pkg/kubectl/cmd/apply/widget-clientside.yaml"
|
filenameWidgetClientside = "../../../test/fixtures/pkg/kubectl/cmd/apply/widget-clientside.yaml"
|
||||||
filenameWidgetServerside = "../../../test/fixtures/pkg/kubectl/cmd/apply/widget-serverside.yaml"
|
filenameWidgetServerside = "../../../test/fixtures/pkg/kubectl/cmd/apply/widget-serverside.yaml"
|
||||||
@@ -229,6 +231,7 @@ func walkMapPath(t *testing.T, start map[string]interface{}, path []string) map[
|
|||||||
|
|
||||||
func TestRunApplyViewLastApplied(t *testing.T) {
|
func TestRunApplyViewLastApplied(t *testing.T) {
|
||||||
_, rcBytesWithConfig := readReplicationController(t, filenameRCLASTAPPLIED)
|
_, rcBytesWithConfig := readReplicationController(t, filenameRCLASTAPPLIED)
|
||||||
|
_, rcBytesWithArgs := readReplicationController(t, filenameRCLastAppliedArgs)
|
||||||
nameRC, rcBytes := readReplicationController(t, filenameRC)
|
nameRC, rcBytes := readReplicationController(t, filenameRC)
|
||||||
pathRC := "/namespaces/test/replicationcontrollers/" + nameRC
|
pathRC := "/namespaces/test/replicationcontrollers/" + nameRC
|
||||||
|
|
||||||
@@ -247,6 +250,16 @@ func TestRunApplyViewLastApplied(t *testing.T) {
|
|||||||
args: []string{},
|
args: []string{},
|
||||||
respBytes: rcBytesWithConfig,
|
respBytes: rcBytesWithConfig,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "test with file include `%s` in arguments",
|
||||||
|
filePath: filenameRCArgs,
|
||||||
|
outputFormat: "",
|
||||||
|
expectedErr: "",
|
||||||
|
expectedOut: "args: -random_flag=%s@domain.com\n",
|
||||||
|
selector: "",
|
||||||
|
args: []string{},
|
||||||
|
respBytes: rcBytesWithArgs,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "view with file json format",
|
name: "view with file json format",
|
||||||
filePath: filenameRC,
|
filePath: filenameRC,
|
||||||
|
20
test/fixtures/pkg/kubectl/cmd/apply/rc-args.yaml
vendored
Normal file
20
test/fixtures/pkg/kubectl/cmd/apply/rc-args.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ReplicationController
|
||||||
|
metadata:
|
||||||
|
name: test-rc
|
||||||
|
labels:
|
||||||
|
name: test-rc
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: test-rc
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: test-rc
|
||||||
|
image: nginx
|
||||||
|
args:
|
||||||
|
- -random_flag=%s@domain.com
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
23
test/fixtures/pkg/kubectl/cmd/apply/rc-lastapplied-args.yaml
vendored
Normal file
23
test/fixtures/pkg/kubectl/cmd/apply/rc-lastapplied-args.yaml
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ReplicationController
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
kubectl.kubernetes.io/last-applied-configuration: |
|
||||||
|
{"args":"-random_flag=%s@domain.com"}
|
||||||
|
name: test-rc
|
||||||
|
labels:
|
||||||
|
name: test-rc
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
name: test-rc
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: test-rc
|
||||||
|
image: nginx
|
||||||
|
args:
|
||||||
|
- -random_flag=%s@domain.com
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
Reference in New Issue
Block a user