mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
kubectl-diff: Test return code on failure and changes
This commit is contained in:
parent
f2b21f08d9
commit
38c5f318c9
8
hack/testdata/invalid-pod.yaml
vendored
Normal file
8
hack/testdata/invalid-pod.yaml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: test
|
||||
spec:
|
||||
containers:
|
||||
- name:
|
||||
image: nginx
|
@ -32,9 +32,18 @@ run_kubectl_diff_tests() {
|
||||
|
||||
kubectl apply -f hack/testdata/pod.yaml
|
||||
|
||||
output_message=$(! kubectl diff -f hack/testdata/pod-changed.yaml)
|
||||
# Make sure that diffing the resource right after returns nothing (0 exit code).
|
||||
kubectl diff -f hack/testdata/pod.yaml
|
||||
|
||||
# Make sure that:
|
||||
# 1. the exit code for diff is 1 because it found a difference
|
||||
# 2. the difference contains the changed image
|
||||
output_message=$(kubectl diff -f hack/testdata/pod-changed.yaml || test $? -eq 1)
|
||||
kube::test::if_has_string "${output_message}" 'k8s.gcr.io/pause:3.0'
|
||||
|
||||
# Test that we have a return code bigger than 1 if there is an error when diffing
|
||||
kubectl diff -f hack/testdata/invalid-pod.yaml || test $? -gt 1
|
||||
|
||||
kubectl delete -f hack/testdata/pod.yaml
|
||||
|
||||
set +o nounset
|
||||
|
Loading…
Reference in New Issue
Block a user