cleanup: address golangci 'usetesting' linter issues

When a context.Context is needed in a unit test, t.Context() should be
used instead of creating a new one with context.TODO() or
context.Background().

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2025-04-29 11:36:03 +02:00
committed by mergify[bot]
parent be5462cf62
commit 457ffe884a
19 changed files with 35 additions and 51 deletions

View File

@ -17,7 +17,6 @@ limitations under the License.
package rbd
import (
"context"
"testing"
"github.com/ceph/ceph-csi/internal/util"
@ -39,7 +38,7 @@ func TestControllerReclaimSpace(t *testing.T) {
Secrets: nil,
}
_, err := controller.ControllerReclaimSpace(context.TODO(), req)
_, err := controller.ControllerReclaimSpace(t.Context(), req)
require.Error(t, err)
}
@ -58,6 +57,6 @@ func TestNodeReclaimSpace(t *testing.T) {
Secrets: nil,
}
_, err := node.NodeReclaimSpace(context.TODO(), req)
_, err := node.NodeReclaimSpace(t.Context(), req)
require.Error(t, err)
}