diff --git a/controllers/appsv1/namespace_controller_test.go b/controllers/appsv1/namespace_controller_test.go index 717289daa..1ac643f46 100644 --- a/controllers/appsv1/namespace_controller_test.go +++ b/controllers/appsv1/namespace_controller_test.go @@ -1,12 +1,16 @@ package appsv1_test import ( + "context" "testing" "github.com/stretchr/testify/require" + "k8s.io/apimachinery/pkg/types" k8sconfig "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" + k8sreconcile "sigs.k8s.io/controller-runtime/pkg/reconcile" + v1 "github.com/jaegertracing/jaeger-operator/apis/v1" "github.com/jaegertracing/jaeger-operator/controllers/appsv1" ) @@ -28,3 +32,24 @@ func TestNamespaceControllerRegisterWithManager(t *testing.T) { // verify require.NoError(t, err) } + +func TestNewNamespaceInstance(t *testing.T) { + // prepare + nsn := types.NamespacedName{Name: "my-instance", Namespace: "default"} + reconciler := appsv1.NewNamespaceReconciler( + k8sClient, + k8sClient, + testScheme, + ) + + instance := v1.NewJaeger(nsn) + err := k8sClient.Create(context.Background(), instance) + require.NoError(t, err) + + req := k8sreconcile.Request{ + NamespacedName: nsn, + } + + _, err = reconciler.Reconcile(context.Background(), req) + require.NoError(t, err) +}