Skip to content

Commit

Permalink
Add example unit test with issuer name
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Dec 3, 2020
1 parent 2e4de87 commit 1503d74
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion cmd/apps/openfaas_ingress_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
}
}

func Test_buildYAML_IngressTakesEmailOverride(t *testing.T) {
func Test_buildYAML_IssuerTakesEmailOverride(t *testing.T) {
templBytes, _ := buildIssuerYAML("openfaas.subdomain.example.com", "[email protected]", "traefik", "openfaas-gateway", false, false, "openfaas")
var want = `
apiVersion: cert-manager.io/v1
Expand Down Expand Up @@ -120,6 +120,38 @@ spec:
}
}

func Test_buildIngress_WithCustomIssuername(t *testing.T) {
templBytes, _ := buildOpenfaasIngressYAML("openfaas.subdomain.example.com", "[email protected]", "traefik", "openfaas-gateway", true, false, "venafi-tpp", "openfaas")
var want = `
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: openfaas-gateway
namespace: openfaas
annotations:
cert-manager.io/issuer: venafi-tpp
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: openfaas.subdomain.example.com
http:
paths:
- backend:
serviceName: gateway
servicePort: 8080
path: /
tls:
- hosts:
- openfaas.subdomain.example.com
secretName: openfaas-gateway
`

got := string(templBytes)
if want != got {
t.Errorf("want:\n%q\ngot:\n%q\n", want, got)
}
}

func Test_buildYAMLClusterIssuer_HasNoNamespace(t *testing.T) {
templBytes, _ := buildIssuerYAML("openfaas.subdomain.example.com", "[email protected]", "traefik", "openfaas-gateway", true, true, "openfaas")
var want = `
Expand Down

0 comments on commit 1503d74

Please sign in to comment.