From b9bf3d44e5d1a33ec01f89a0c67ec6ba02d91738 Mon Sep 17 00:00:00 2001 From: Matous Jobanek Date: Thu, 16 Jan 2025 09:59:51 +0100 Subject: [PATCH] update helper function names (#1121) --- .../usersignup/usersignup_controller_test.go | 5 ++-- .../usersignup_cleanup_controller_test.go | 30 +++++++++---------- go.mod | 2 +- go.sum | 4 +-- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/controllers/usersignup/usersignup_controller_test.go b/controllers/usersignup/usersignup_controller_test.go index 0e1f69182..27f16e2d0 100644 --- a/controllers/usersignup/usersignup_controller_test.go +++ b/controllers/usersignup/usersignup_controller_test.go @@ -5,11 +5,12 @@ import ( "errors" "fmt" "os" - "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "strings" "testing" "time" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + . "github.com/codeready-toolchain/host-operator/pkg/space" toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1" @@ -3135,7 +3136,7 @@ func TestUserSignupBannedWithoutMURAndSpace(t *testing.T) { func TestUserSignupVerificationRequired(t *testing.T) { // given - userSignup := commonsignup.NewUserSignup(commonsignup.VerificationRequired(0)) + userSignup := commonsignup.NewUserSignup(commonsignup.VerificationRequired()) r, req, _ := prepareReconcile(t, userSignup.Name, userSignup, commonconfig.NewToolchainConfigObjWithReset(t, testconfig.AutomaticApproval().Enabled(true)), baseNSTemplateTier) InitializeCounters(t, NewToolchainStatus( diff --git a/controllers/usersignupcleanup/usersignup_cleanup_controller_test.go b/controllers/usersignupcleanup/usersignup_cleanup_controller_test.go index 769ece06d..61e85627c 100644 --- a/controllers/usersignupcleanup/usersignup_cleanup_controller_test.go +++ b/controllers/usersignupcleanup/usersignup_cleanup_controller_test.go @@ -63,7 +63,7 @@ func TestUserCleanup(t *testing.T) { userSignup := commonsignup.NewUserSignup( commonsignup.ApprovedManuallyAgo(fiveYears), commonsignup.WithStateLabel(toolchainv1alpha1.UserSignupStateLabelValueApproved), - commonsignup.DeactivatedWithLastTransitionTime(time.Duration(5*time.Minute)), + commonsignup.DeactivatedAgo(5*time.Minute), commonsignup.CreatedBefore(fiveYears), ) @@ -85,7 +85,7 @@ func TestUserCleanup(t *testing.T) { userSignup := commonsignup.NewUserSignup( commonsignup.WithStateLabel(toolchainv1alpha1.UserSignupStateLabelValueApproved), commonsignup.ApprovedManuallyAgo(fiveYears), - commonsignup.DeactivatedWithLastTransitionTime(fiveYears), + commonsignup.DeactivatedAgo(fiveYears), commonsignup.CreatedBefore(fiveYears), ) @@ -111,7 +111,7 @@ func TestUserCleanup(t *testing.T) { userSignup := commonsignup.NewUserSignup( commonsignup.CreatedBefore(days(8)), - commonsignup.VerificationRequired(days(8)), + commonsignup.VerificationRequiredAgo(days(8)), commonsignup.WithActivations("0"), ) @@ -142,7 +142,7 @@ func TestUserCleanup(t *testing.T) { // given userSignup := commonsignup.NewUserSignup( commonsignup.CreatedBefore(days(8)), - commonsignup.VerificationRequired(days(8)), + commonsignup.VerificationRequiredAgo(days(8)), ) r, req, _ := prepareReconcile(t, userSignup.Name, userSignup) // when @@ -167,7 +167,7 @@ func TestUserCleanup(t *testing.T) { // given userSignup := commonsignup.NewUserSignup( commonsignup.CreatedBefore(days(8)), - commonsignup.VerificationRequired(days(8)), + commonsignup.VerificationRequiredAgo(days(8)), commonsignup.WithAnnotation(toolchainv1alpha1.UserSignupVerificationCodeAnnotationKey, "12345"), ) r, req, _ := prepareReconcile(t, userSignup.Name, userSignup) @@ -194,7 +194,7 @@ func TestUserCleanup(t *testing.T) { userSignup := commonsignup.NewUserSignup( commonsignup.CreatedBefore(fiveYears), commonsignup.ApprovedManuallyAgo(days(40)), - commonsignup.VerificationRequired(days(10)), + commonsignup.VerificationRequiredAgo(days(10)), commonsignup.WithActivations("1"), ) @@ -216,7 +216,7 @@ func TestUserCleanup(t *testing.T) { userSignup := commonsignup.NewUserSignup( commonsignup.CreatedBefore(fiveYears), commonsignup.ApprovedManuallyAgo(days(730+21)), - commonsignup.VerificationRequired(days(730+1)), + commonsignup.VerificationRequiredAgo(days(730+1)), commonsignup.WithActivations("2"), ) @@ -266,35 +266,35 @@ func TestUserCleanup(t *testing.T) { }{ "test that a UserSignup older than 2 years, with 1 activation and not banned, is deleted": { userSignup: commonsignup.NewUserSignup( - commonsignup.DeactivatedWithLastTransitionTime(twoYears), + commonsignup.DeactivatedAgo(twoYears), commonsignup.WithActivations("1")), expectedError: "", expectedToBeDeleted: true, }, "test that a UserSignup older than 2 years, with indeterminate activations and not banned, is deleted": { userSignup: commonsignup.NewUserSignup( - commonsignup.DeactivatedWithLastTransitionTime(twoYears), + commonsignup.DeactivatedAgo(twoYears), commonsignup.WithActivations("unknown")), expectedError: "", expectedToBeDeleted: true, }, "test that a UserSignup 1 year old, with 1 activation and not banned, is not deleted": { userSignup: commonsignup.NewUserSignup( - commonsignup.DeactivatedWithLastTransitionTime(oneYear), + commonsignup.DeactivatedAgo(oneYear), commonsignup.WithActivations("1")), expectedError: "", expectedToBeDeleted: false, }, "test that a UserSignup older than 2 years, with 2 activations and not banned, is not deleted": { userSignup: commonsignup.NewUserSignup( - commonsignup.DeactivatedWithLastTransitionTime(twoYears), + commonsignup.DeactivatedAgo(twoYears), commonsignup.WithActivations("2")), expectedError: "", expectedToBeDeleted: false, }, "test that a UserSignup older than 2 years, with 1 activation but has been banned, is not deleted": { userSignup: commonsignup.NewUserSignup( - commonsignup.DeactivatedWithLastTransitionTime(twoYears), + commonsignup.DeactivatedAgo(twoYears), commonsignup.WithActivations("1")), banned: true, expectedError: "", @@ -302,7 +302,7 @@ func TestUserCleanup(t *testing.T) { }, "test that a banned UserSignup with an invalid email hash returns an error and is not deleted": { userSignup: commonsignup.NewUserSignup( - commonsignup.DeactivatedWithLastTransitionTime(twoYears), + commonsignup.DeactivatedAgo(twoYears), commonsignup.WithActivations("1"), commonsignup.WithName("invalid-email-user"), commonsignup.WithLabel(toolchainv1alpha1.UserSignupUserEmailHashLabelKey, "INVALID")), @@ -312,7 +312,7 @@ func TestUserCleanup(t *testing.T) { }, "test that a UserSignup without an email address returns an error and is not deleted": { userSignup: commonsignup.NewUserSignup( - commonsignup.DeactivatedWithLastTransitionTime(twoYears), + commonsignup.DeactivatedAgo(twoYears), commonsignup.WithActivations("1"), commonsignup.WithName("without-email-user"), commonsignup.WithEmail("")), @@ -371,7 +371,7 @@ func TestUserCleanup(t *testing.T) { t.Run("test propagation policy", func(t *testing.T) { userSignup := commonsignup.NewUserSignup( commonsignup.CreatedBefore(fiveYears), - commonsignup.VerificationRequired(days(8)), + commonsignup.VerificationRequiredAgo(days(8)), ) r, req, fakeClient := prepareReconcile(t, userSignup.Name, userSignup) diff --git a/go.mod b/go.mod index 9b568ba48..a01433c3a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/codeready-toolchain/host-operator require ( cloud.google.com/go/recaptchaenterprise/v2 v2.13.0 github.com/codeready-toolchain/api v0.0.0-20241119094246-f6581d52dc80 - github.com/codeready-toolchain/toolchain-common v0.0.0-20241128143121-e2e3546a35e9 + github.com/codeready-toolchain/toolchain-common v0.0.0-20250113092648-1078d683961b github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-bindata/go-bindata v3.1.2+incompatible github.com/go-logr/logr v1.4.1 diff --git a/go.sum b/go.sum index 2f58096b8..f5f1e1675 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBS github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/codeready-toolchain/api v0.0.0-20241119094246-f6581d52dc80 h1:OpZkP3OGAdrDHOb1TtHVnLSVuevEiQhOH//plnpVL/c= github.com/codeready-toolchain/api v0.0.0-20241119094246-f6581d52dc80/go.mod h1:DUq1ffy9Mbersdgji48i/cm9Y+6NMwAdAQJNlfOrPRo= -github.com/codeready-toolchain/toolchain-common v0.0.0-20241128143121-e2e3546a35e9 h1:urMWj0TK944x2zZhVEvcNklLzPbarWBaxLGhyeXdLi0= -github.com/codeready-toolchain/toolchain-common v0.0.0-20241128143121-e2e3546a35e9/go.mod h1:4MD8PrbljFH7qSF44EjzAs2HVdr1R/vrsii2eO8Im+4= +github.com/codeready-toolchain/toolchain-common v0.0.0-20250113092648-1078d683961b h1:zlLUDN9ddogCX8hzuPrIdS/YpAF8siucA5b56zGUz00= +github.com/codeready-toolchain/toolchain-common v0.0.0-20250113092648-1078d683961b/go.mod h1:wLXGFyEan+RJHZEEMmvTxNa2BrlizIA+4+Lsi1cyuAk= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=