Adding test for new function

This commit is contained in:
Amit Kumar 2018-03-07 16:08:35 +00:00
parent cef2e6f5e2
commit fedcffee9d
No known key found for this signature in database
GPG key ID: 3DD124873C5CD108

View file

@ -18,6 +18,7 @@ package store
import (
"encoding/base64"
"testing"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -127,6 +128,26 @@ func buildCrtKeyAndCA() ([]byte, []byte, []byte, error) {
return dCrt, dKey, dCa, nil
}
func TestGetSecretKey(t *testing.T) {
secretName := "secretNamespace/superSecret"
ingressNamespace := "ingressNamespace"
// Test when secret is in not in the same namespace as ingress.
secretKey := getSecretKey(ingressNamespace, secretName)
if secretKey != "secretNamespace/superSecret" {
t.Errorf("expected 0 items in the store but %v returned", secretKey)
}
// Test when secret resides in the same namespace as ingress.
secretName = "superSecret"
secretKey = getSecretKey(ingressNamespace, secretName)
if secretKey != "ingressNamespace/superSecret" {
t.Errorf("expected 0 items in the store but %v returned", secretKey)
}
}
/*
func TestSyncSecret(t *testing.T) {
// prepare for test