Skip to content

nautobot_controller_test.go reconcile test fails — missing nautobotSecretRef setup #2193

Description

@geetikabatra

Description

The scaffolded test in
nautobot_controller_test.go creates a Nautobot CR without setting nautobotSecretRef and expects Reconcile to succeed. It fails with:

failed to get nautobot auth token {"error": "nautobotSecretRef "" is missing a namespace"}
Steps to Reproduce

make test
The failing test is:

Nautobot Controller When reconciling a resource [It] should successfully reconcile the resource
nautobot_controller_test.go:79

Root Cause

The test creates a bare Nautobot CR with no spec fields populated:

resource := &syncv1alpha1.Nautobot{
    ObjectMeta: metav1.ObjectMeta{
        Name:      resourceName,
        Namespace: "default",
    },
}

When Reconcile runs, it reaches getAuthTokenFromSecretRef which requires nautobotSecretRef.Name and nautobotSecretRef.Namespace to be set.

Expected Fix

Provide a valid nautobotSecretRef — create a Secret in the test namespace and reference it in the CR spec

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions