Skip to content

Commit

Permalink
feat: added unit test for namespace reconciler (#2659)
Browse files Browse the repository at this point in the history
Signed-off-by: Ankit152 <[email protected]>
  • Loading branch information
Ankit152 authored Aug 14, 2024
1 parent 090a231 commit e5546c7
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions controllers/appsv1/namespace_controller_test.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand All @@ -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)
}

0 comments on commit e5546c7

Please sign in to comment.