Skip to content

Commit

Permalink
Add test case for Ingress object
Browse files Browse the repository at this point in the history
The test tries to decode the Ingress as a networking.k8s.io/v1 Ingress
object, and panics if the apiVersion is wrong.
  • Loading branch information
simu committed Nov 10, 2021
1 parent d09bdae commit 6caffe5
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/builtin/ingress_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package builtin

import (
"testing"

"github.com/projectsyn/component-keycloak/common"
)


func Test_IngressApiVersion(t *testing.T) {
common.IngressApiVersionTest(t, testPath)
}
19 changes: 19 additions & 0 deletions tests/common/apiversion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package common

import (
"testing"

"github.com/stretchr/testify/assert"
networkingv1 "k8s.io/api/networking/v1"
)

var (
ingressPath = "/01_keycloak_helmchart/keycloak/templates/ingress.yaml"
)

func IngressApiVersionTest(t *testing.T, basepath string) {
subject := &networkingv1.Ingress{}
scheme := NewSchemeWithDefault(t)
ingress := DecodeWithSchema(t, basepath+ingressPath, subject,scheme).(*networkingv1.Ingress)
assert.Equal(t, "keycloak", ingress.Name)
}
12 changes: 12 additions & 0 deletions tests/external/ingress_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package external

import (
"testing"

"github.com/projectsyn/component-keycloak/common"
)


func Test_IngressApiVersion(t *testing.T) {
common.IngressApiVersionTest(t, testPath)
}

0 comments on commit 6caffe5

Please sign in to comment.