diff: Fix broken Local() logic

Local and Live functions where doing and returning the same thing,
giving empty results by default. Fix the local function by copying the
objects before fetching the live version.
This commit is contained in:
Antoine Pelisse
2018-03-15 10:06:51 -07:00
parent bd0d093701
commit f2b48a90df
2 changed files with 98 additions and 16 deletions

View File

@@ -1185,6 +1185,39 @@ run_kubectl_apply_deployments_tests() {
set +o errexit
}
# Runs tests for kubectl alpha diff
run_kubectl_diff_tests() {
set -o nounset
set -o errexit
create_and_use_new_namespace
kube::log::status "Testing kubectl alpha diff"
kubectl apply -f hack/testdata/pod.yaml
# Ensure that selfLink has been added, and shown in the diff
output_message=$(kubectl alpha diff -f hack/testdata/pod.yaml)
kube::test::if_has_string "${output_message}" 'selfLink'
output_message=$(kubectl alpha diff LOCAL LIVE -f hack/testdata/pod.yaml)
kube::test::if_has_string "${output_message}" 'selfLink'
output_message=$(kubectl alpha diff LOCAL MERGED -f hack/testdata/pod.yaml)
kube::test::if_has_string "${output_message}" 'selfLink'
output_message=$(kubectl alpha diff MERGED MERGED -f hack/testdata/pod.yaml)
kube::test::if_empty_string "${output_message}"
output_message=$(kubectl alpha diff LIVE LIVE -f hack/testdata/pod.yaml)
kube::test::if_empty_string "${output_message}"
output_message=$(kubectl alpha diff LAST LAST -f hack/testdata/pod.yaml)
kube::test::if_empty_string "${output_message}"
output_message=$(kubectl alpha diff LOCAL LOCAL -f hack/testdata/pod.yaml)
kube::test::if_empty_string "${output_message}"
kubectl delete -f hack/testdata/pod.yaml
set +o nounset
set +o errexit
}
# Runs tests for --save-config tests.
run_save_config_tests() {
set -o nounset
@@ -4983,6 +5016,11 @@ runTests() {
record_command run_kubectl_apply_deployments_tests
fi
################
# Kubectl diff #
################
record_command run_kubectl_diff_tests
###############
# Kubectl get #
###############