mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
add tests
This commit is contained in:
parent
1d54dc4136
commit
dd45076f8e
@ -915,6 +915,32 @@ __EOF__
|
||||
set +o errexit
|
||||
}
|
||||
|
||||
# runs specific kubectl create tests
|
||||
run_create_tests() {
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
|
||||
### Create generic secret with explicit namespace
|
||||
# Pre-condition: secret 'mysecret' does not exist
|
||||
output_message=$(! kubectl get secrets mysecret 2>&1 "${kube_flags[@]}")
|
||||
kube::test::if_has_string "${output_message}" 'secrets "mysecret" not found'
|
||||
# Command
|
||||
output_message=$(kubectl create "${kube_flags[@]}" secret generic mysecret --dry-run --from-literal=foo=bar -o jsonpath='{.metadata.namespace}' --namespace=user-specified)
|
||||
# Post-condition: mysecret still not created since --dry-run was used
|
||||
# Output from 'create' command should contain the specified --namespace value
|
||||
failure_message=$(! kubectl get secrets mysecret 2>&1 "${kube_flags[@]}")
|
||||
kube::test::if_has_string "${failure_message}" 'secrets "mysecret" not found'
|
||||
kube::test::if_has_string "${output_message}" 'user-specified'
|
||||
# Command
|
||||
output_message=$(kubectl create "${kube_flags[@]}" secret generic mysecret --dry-run --from-literal=foo=bar -o jsonpath='{.metadata.namespace}')
|
||||
# Post-condition: jsonpath for .metadata.namespace should be empty for object since --namespace was not explicitly specified
|
||||
kube::test::if_empty_string "${output_message}"
|
||||
|
||||
set +o nounset
|
||||
set +o errexit
|
||||
}
|
||||
|
||||
|
||||
# Runs tests related to kubectl apply.
|
||||
run_kubectl_apply_tests() {
|
||||
set -o nounset
|
||||
@ -4560,6 +4586,14 @@ runTests() {
|
||||
record_command run_kubectl_get_tests
|
||||
fi
|
||||
|
||||
|
||||
######################
|
||||
# Create #
|
||||
######################
|
||||
if kube::test::if_supports_resource "${secrets}" ; then
|
||||
record_command run_create_tests
|
||||
fi
|
||||
|
||||
##################
|
||||
# Global timeout #
|
||||
##################
|
||||
|
Loading…
Reference in New Issue
Block a user