Skip to content

Commit

Permalink
cleanup packages being imported more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoaresd committed Mar 21, 2024
1 parent 188cb8a commit d127054
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 171 deletions.
31 changes: 15 additions & 16 deletions controllers/masteruserrecord/masteruserrecord_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)
Expand All @@ -40,7 +39,7 @@ var testLog = ctrl.Log.WithName("test")

func TestAddFinalizer(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
signup := commonsignup.NewUserSignup(commonsignup.WithName("john-123"))
mur := murtest.NewMasterUserRecord(t, "john", murtest.WithOwnerLabel("john-123"))
Expand Down Expand Up @@ -197,7 +196,7 @@ func TestAddFinalizer(t *testing.T) {

func TestCreateUserAccountSuccessful(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john",
murtest.WithOwnerLabel("john-123"))
Expand Down Expand Up @@ -249,7 +248,7 @@ func TestCreateUserAccountSuccessful(t *testing.T) {

func TestUserAccountSynchronizeSuccessfulWhenPropagatedClaimsModified(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)

signup := commonsignup.NewUserSignup(commonsignup.WithName("ricky-123"))
Expand Down Expand Up @@ -332,7 +331,7 @@ func TestUserAccountSynchronizeSuccessfulWhenPropagatedClaimsModified(t *testing

func TestCreateUserAccountWhenItWasPreviouslyDeleted(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john",
murtest.WithOwnerLabel("john-123"),
Expand Down Expand Up @@ -380,7 +379,7 @@ func TestCreateUserAccountWhenItWasPreviouslyDeleted(t *testing.T) {

func TestWithMultipleMembersAndSpaces(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)

signup := commonsignup.NewUserSignup(commonsignup.WithName("john-123"))
Expand Down Expand Up @@ -626,7 +625,7 @@ func TestWithMultipleMembersAndSpaces(t *testing.T) {

func TestRequeueWhenUserAccountDeleted(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john", murtest.AdditionalAccounts(commontest.Member2ClusterName), murtest.Finalizer("finalizer.toolchain.dev.openshift.com"))
userAccount1 := uatest.NewUserAccountFromMur(mur)
Expand Down Expand Up @@ -673,7 +672,7 @@ func TestRequeueWhenUserAccountDeleted(t *testing.T) {

func TestCreateSynchronizeOrDeleteUserAccountFailed(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john",
murtest.Finalizer("finalizer.toolchain.dev.openshift.com"),
Expand Down Expand Up @@ -974,7 +973,7 @@ func TestCreateSynchronizeOrDeleteUserAccountFailed(t *testing.T) {
// todo change test to support updates of multiple UserAccounts
func TestModifyUserAccount(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john",
murtest.WithOwnerLabel("john-123"),
Expand Down Expand Up @@ -1033,7 +1032,7 @@ func TestModifyUserAccount(t *testing.T) {
}

func TestSyncMurStatusWithUserAccountStatuses(t *testing.T) {
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
spaceBinding := spacebindingtest.NewSpaceBinding("john", "john-space", "admin", "john-123")
space := spacetest.NewSpace(commontest.HostOperatorNs, "john-space",
Expand Down Expand Up @@ -1193,7 +1192,7 @@ func TestDeleteUserAccountViaMasterUserRecordBeingDeleted(t *testing.T) {

t.Run("success", func(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john",
murtest.ToBeDeleted())
Expand Down Expand Up @@ -1233,7 +1232,7 @@ func TestDeleteUserAccountViaMasterUserRecordBeingDeleted(t *testing.T) {

t.Run("test wait for UserAccount deletion in progress before removing MUR finalizer", func(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john-wait-for-ua",
murtest.ToBeDeleted())
Expand Down Expand Up @@ -1277,7 +1276,7 @@ func TestDeleteUserAccountViaMasterUserRecordBeingDeleted(t *testing.T) {

t.Run("test wait for UserAccount deletion takes too long", func(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)

// A basic userSignup to set as the mur owner
Expand Down Expand Up @@ -1313,7 +1312,7 @@ func TestDeleteUserAccountViaMasterUserRecordBeingDeleted(t *testing.T) {

t.Run("test UserAccount deletion has foreground propagation policy", func(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john-wait-for-ua",
murtest.ToBeDeleted())
Expand Down Expand Up @@ -1345,7 +1344,7 @@ func TestDeleteUserAccountViaMasterUserRecordBeingDeleted(t *testing.T) {

func TestDeleteMultipleUserAccountsViaMasterUserRecordBeingDeleted(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john",
murtest.Finalizer("finalizer.toolchain.dev.openshift.com"),
Expand Down Expand Up @@ -1400,7 +1399,7 @@ func TestDeleteMultipleUserAccountsViaMasterUserRecordBeingDeleted(t *testing.T)

func TestDisablingMasterUserRecord(t *testing.T) {
// given
logf.SetLogger(zap.New(zap.UseDevMode(true)))
log.SetLogger(zap.New(zap.UseDevMode(true)))
s := apiScheme(t)
mur := murtest.NewMasterUserRecord(t, "john",
murtest.WithOwnerLabel("john-123"),
Expand Down
3 changes: 1 addition & 2 deletions controllers/masteruserrecord/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)

Expand Down Expand Up @@ -840,7 +839,7 @@ func TestRemoveAccountFromStatus(t *testing.T) {
func TestRoutes(t *testing.T) {
// given
l := zap.New(zap.UseDevMode(true))
logf.SetLogger(l)
log.SetLogger(l)
apiScheme(t)

masterUserRec := murtest.NewMasterUserRecord(t, "john",
Expand Down
5 changes: 2 additions & 3 deletions controllers/notification/notification_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/spf13/cast"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
apiv1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -353,7 +352,7 @@ func AssertThatNotificationIsDeleted(t *testing.T, cl runtimeclient.Client, name
func sentCond() toolchainv1alpha1.Condition {
return toolchainv1alpha1.Condition{
Type: toolchainv1alpha1.NotificationSent,
Status: apiv1.ConditionTrue,
Status: corev1.ConditionTrue,
Reason: "Sent",
LastTransitionTime: metav1.Time{Time: time.Now()},
}
Expand All @@ -371,7 +370,7 @@ func deliveryErrorCond(msg string) toolchainv1alpha1.Condition {
func deletionCond(msg string) toolchainv1alpha1.Condition {
return toolchainv1alpha1.Condition{
Type: toolchainv1alpha1.NotificationDeletionError,
Status: apiv1.ConditionTrue,
Status: corev1.ConditionTrue,
Reason: toolchainv1alpha1.NotificationDeletionErrorReason,
Message: msg,
LastTransitionTime: metav1.Time{Time: time.Now()},
Expand Down
3 changes: 1 addition & 2 deletions controllers/spacerequest/space_spacerequest_mapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/codeready-toolchain/host-operator/controllers/spacerequest"
spacerequesttest "github.com/codeready-toolchain/host-operator/test/spacerequest"
"github.com/codeready-toolchain/toolchain-common/pkg/test"
"github.com/codeready-toolchain/toolchain-common/pkg/test/space"
spacetest "github.com/codeready-toolchain/toolchain-common/pkg/test/space"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -19,7 +18,7 @@ func TestMapToSpaceRequestByLabel(t *testing.T) {
// given
spaceRequest := spacerequesttest.NewSpaceRequest("mySpaceRequest", "jane")
// following space has a spaceRequest associated
subSpace := spacetest.NewSpace(test.HostOperatorNs, "subSpace", space.WithLabel(v1alpha1.SpaceRequestLabelKey, spaceRequest.GetName()), space.WithLabel(v1alpha1.SpaceRequestNamespaceLabelKey, spaceRequest.GetNamespace()))
subSpace := spacetest.NewSpace(test.HostOperatorNs, "subSpace", spacetest.WithLabel(v1alpha1.SpaceRequestLabelKey, spaceRequest.GetName()), spacetest.WithLabel(v1alpha1.SpaceRequestNamespaceLabelKey, spaceRequest.GetNamespace()))
// following space has no spaceRequest associated
spacenosr := spacetest.NewSpace(test.HostOperatorNs, "nospacerequest")

Expand Down
Loading

0 comments on commit d127054

Please sign in to comment.