test/unit: finish inject tests

This commit is contained in:
Mitchell Hashimoto 2018-09-03 09:34:28 -07:00
parent fc6d86b96d
commit f20934a89d
No known key found for this signature in database
GPG key ID: 744E147AA52F5B0A
4 changed files with 88 additions and 2 deletions

View file

@ -1,5 +1,5 @@
# The MutatingWebhookConfiguration to enable the Connect injector.
{{- if (default .Values.connectInject.enabled .Values.global.enabled) }}
{{- if (or (and (ne (.Values.connectInject.enabled | toString) "-") .Values.connectInject.enabled) (and (eq (.Values.connectInject.enabled | toString) "-") .Values.global.enabled)) }}
apiVersion: admissionregistration.k8s.io/v1beta1
kind: MutatingWebhookConfiguration
metadata:

View file

@ -1,5 +1,5 @@
# The service for the Connect sidecar injector
{{- if (default .Values.connectInject.enabled .Values.global.enabled) }}
{{- if (or (and (ne (.Values.connectInject.enabled | toString) "-") .Values.connectInject.enabled) (and (eq (.Values.connectInject.enabled | toString) "-") .Values.global.enabled)) }}
apiVersion: v1
kind: Service
metadata:

View file

@ -0,0 +1,43 @@
#!/usr/bin/env bats
load _helpers
@test "connectInject/MutatingWebhookConfiguration: enabled by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-mutatingwebhook.yaml \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "connectInject/MutatingWebhookConfiguration: enable with global.enabled false" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-mutatingwebhook.yaml \
--set 'global.enabled=false' \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "connectInject/MutatingWebhookConfiguration: disable with connectInject.enabled" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-mutatingwebhook.yaml \
--set 'connectInject.enabled=false' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "connectInject/MutatingWebhookConfiguration: disable with global.enabled" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-mutatingwebhook.yaml \
--set 'global.enabled=false' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}

View file

@ -0,0 +1,43 @@
#!/usr/bin/env bats
load _helpers
@test "connectInject/Service: enabled by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-service.yaml \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "connectInject/Service: enable with global.enabled false" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-service.yaml \
--set 'global.enabled=false' \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
@test "connectInject/Service: disable with connectInject.enabled" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-service.yaml \
--set 'connectInject.enabled=false' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}
@test "connectInject/Service: disable with global.enabled" {
cd `chart_dir`
local actual=$(helm template \
-x templates/connect-inject-service.yaml \
--set 'global.enabled=false' \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
}