From caa2b3521424ba9f68955646db62726c521c855f Mon Sep 17 00:00:00 2001 From: davidby-influx Date: Tue, 19 Dec 2023 13:59:50 -0800 Subject: [PATCH] fix: refactor for review suggestions --- authorization/middleware_auth_test.go | 12 ++--- authorizer/auth_test.go | 12 ++--- authorizer/bucket_test.go | 12 ++--- authorizer/check_test.go | 12 ++--- authorizer/dashboard_test.go | 22 ++++---- authorizer/label_test.go | 16 +++--- authorizer/notification_endpoint_test.go | 12 ++--- authorizer/notification_rule_test.go | 12 ++--- authorizer/org_test.go | 12 ++--- authorizer/scraper_test.go | 10 ++-- authorizer/secret_test.go | 12 ++--- authorizer/source_test.go | 12 ++--- authorizer/telegraf_test.go | 10 ++-- authorizer/urm_test.go | 6 +-- authorizer/user_test.go | 12 ++--- authorizer/variable_test.go | 12 ++--- dbrp/middleware_auth_test.go | 10 ++-- label/middleware_auth_test.go | 16 +++--- notification/check/check_test.go | 2 +- notification/endpoint/endpoint_test.go | 2 +- notification/rule/rule_test.go | 2 +- notification/rule/telegram_test.go | 2 +- predicate/parser_test.go | 4 +- predicate/predicate_test.go | 2 +- secret/middleware_auth_test.go | 12 ++--- tag_test.go | 2 +- tenant/http_server_bucket_test.go | 2 +- tenant/http_server_org_test.go | 2 +- tenant/http_server_user_test.go | 2 +- tenant/middleware_bucket_auth_test.go | 12 ++--- tenant/middleware_org_auth_test.go | 12 ++--- tenant/middleware_org_logging_test.go | 2 +- tenant/middleware_urm_auth_test.go | 8 +-- tenant/middleware_user_auth_test.go | 12 ++--- tenant/middleware_user_logging_test.go | 2 +- tenant/service_org_test.go | 2 +- tenant/service_user_test.go | 2 +- testing/auth.go | 12 ++--- testing/bucket_service.go | 12 ++--- testing/label_service.go | 14 ++--- testing/organization_service.go | 61 ++++++++-------------- testing/scraper_target.go | 10 ++-- testing/session.go | 8 +-- testing/source.go | 8 +-- testing/user_service.go | 66 ++++++++---------------- testing/util.go | 16 +++--- testing/variable.go | 2 +- 47 files changed, 238 insertions(+), 279 deletions(-) diff --git a/authorization/middleware_auth_test.go b/authorization/middleware_auth_test.go index e98f2ee01de..7ed49182a99 100644 --- a/authorization/middleware_auth_test.go +++ b/authorization/middleware_auth_test.go @@ -177,16 +177,16 @@ func TestAuthorizationService_ReadAuthorization(t *testing.T) { t.Run("find authorization by id", func(t *testing.T) { _, err := s.FindAuthorizationByID(ctx, 10) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) t.Run("find authorization by token", func(t *testing.T) { _, err := s.FindAuthorizationByToken(ctx, "10") - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) t.Run("find authorizations", func(t *testing.T) { as, _, err := s.FindAuthorizations(ctx, influxdb.AuthorizationFilter{}) - influxdbtesting.ErrorsEqual(t, err, nil, false) + influxdbtesting.ErrorsEqual(t, err, nil) if diff := cmp.Diff(as, tt.wants.authorizations, authorizationCmpOptions...); diff != "" { t.Errorf("authorizations are different -got/+want\ndiff %s", diff) @@ -323,12 +323,12 @@ func TestAuthorizationService_WriteAuthorization(t *testing.T) { t.Run("update authorization", func(t *testing.T) { _, err := s.UpdateAuthorization(ctx, 10, &influxdb.AuthorizationUpdate{Status: influxdb.Active.Ptr()}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) t.Run("delete authorization", func(t *testing.T) { err := s.DeleteAuthorization(ctx, 10) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) }) @@ -461,7 +461,7 @@ func TestAuthorizationService_CreateAuthorization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.CreateAuthorization(ctx, &influxdb.Authorization{OrgID: 1, UserID: 1}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/auth_test.go b/authorizer/auth_test.go index d23e0cd0d20..3f1538db230 100644 --- a/authorizer/auth_test.go +++ b/authorizer/auth_test.go @@ -165,16 +165,16 @@ func TestAuthorizationService_ReadAuthorization(t *testing.T) { t.Run("find authorization by id", func(t *testing.T) { _, err := s.FindAuthorizationByID(ctx, 10) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) t.Run("find authorization by token", func(t *testing.T) { _, err := s.FindAuthorizationByToken(ctx, "10") - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) t.Run("find authorizations", func(t *testing.T) { as, _, err := s.FindAuthorizations(ctx, influxdb.AuthorizationFilter{}) - influxdbtesting.ErrorsEqual(t, err, nil, false) + influxdbtesting.ErrorsEqual(t, err, nil) if diff := cmp.Diff(as, tt.wants.authorizations, authorizationCmpOptions...); diff != "" { t.Errorf("authorizations are different -got/+want\ndiff %s", diff) @@ -304,12 +304,12 @@ func TestAuthorizationService_WriteAuthorization(t *testing.T) { t.Run("update authorization", func(t *testing.T) { _, err := s.UpdateAuthorization(ctx, 10, &influxdb.AuthorizationUpdate{Status: influxdb.Active.Ptr()}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) t.Run("delete authorization", func(t *testing.T) { err := s.DeleteAuthorization(ctx, 10) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) }) @@ -434,7 +434,7 @@ func TestAuthorizationService_CreateAuthorization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.CreateAuthorization(ctx, &influxdb.Authorization{OrgID: 1, UserID: 1}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/bucket_test.go b/authorizer/bucket_test.go index eed4a5088b1..81faf2e01e4 100644 --- a/authorizer/bucket_test.go +++ b/authorizer/bucket_test.go @@ -112,7 +112,7 @@ func TestBucketService_FindBucketByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindBucketByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -197,7 +197,7 @@ func TestBucketService_FindBucket(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindBucket(ctx, influxdb.BucketFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -322,7 +322,7 @@ func TestBucketService_FindBuckets(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) buckets, _, err := s.FindBuckets(ctx, influxdb.BucketFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(buckets, tt.wants.buckets, bucketCmpOptions...); diff != "" { t.Errorf("buckets are different -got/+want\ndiff %s", diff) @@ -437,7 +437,7 @@ func TestBucketService_UpdateBucket(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateBucket(ctx, tt.args.id, influxdb.BucketUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -542,7 +542,7 @@ func TestBucketService_DeleteBucket(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteBucket(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -624,7 +624,7 @@ func TestBucketService_CreateBucket(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateBucket(ctx, &influxdb.Bucket{OrgID: tt.args.orgID}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/check_test.go b/authorizer/check_test.go index 00ecb7b865a..f90c1a91d80 100644 --- a/authorizer/check_test.go +++ b/authorizer/check_test.go @@ -117,7 +117,7 @@ func TestCheckService_FindCheckByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindCheckByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -263,7 +263,7 @@ func TestCheckService_FindChecks(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) ts, _, err := s.FindChecks(ctx, influxdb.CheckFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(ts, tt.wants.checks, checkCmpOptions...); diff != "" { t.Errorf("checks are different -got/+want\ndiff %s", diff) @@ -391,7 +391,7 @@ func TestCheckService_UpdateCheck(t *testing.T) { } _, err := s.UpdateCheck(ctx, tt.args.id, cc) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -510,7 +510,7 @@ func TestCheckService_PatchCheck(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.PatchCheck(ctx, tt.args.id, influxdb.CheckUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -619,7 +619,7 @@ func TestCheckService_DeleteCheck(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteCheck(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -711,7 +711,7 @@ func TestCheckService_CreateCheck(t *testing.T) { } err := s.CreateCheck(ctx, cc, 3) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/dashboard_test.go b/authorizer/dashboard_test.go index 48dff16972d..f817b92c9dc 100644 --- a/authorizer/dashboard_test.go +++ b/authorizer/dashboard_test.go @@ -112,7 +112,7 @@ func TestDashboardService_FindDashboardByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindDashboardByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -237,7 +237,7 @@ func TestDashboardService_FindDashboards(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) dashboards, _, err := s.FindDashboards(ctx, influxdb.DashboardFilter{}, influxdb.FindOptions{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(dashboards, tt.wants.dashboards, dashboardCmpOptions...); diff != "" { t.Errorf("dashboards are different -got/+want\ndiff %s", diff) @@ -352,7 +352,7 @@ func TestDashboardService_UpdateDashboard(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateDashboard(ctx, tt.args.id, influxdb.DashboardUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -457,7 +457,7 @@ func TestDashboardService_DeleteDashboard(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteDashboard(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -539,7 +539,7 @@ func TestDashboardService_CreateDashboard(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateDashboard(ctx, &influxdb.Dashboard{OrganizationID: tt.args.orgID}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -657,19 +657,19 @@ func TestDashboardService_WriteDashboardCell(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.AddDashboardCell(ctx, 1, &influxdb.Cell{}, influxdb.AddDashboardCellOptions{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) err = s.RemoveDashboardCell(ctx, 1, 2) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) _, err = s.UpdateDashboardCellView(ctx, 1, 2, influxdb.ViewUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) _, err = s.UpdateDashboardCell(ctx, 1, 2, influxdb.CellUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) err = s.ReplaceDashboardCells(ctx, 1, []*influxdb.Cell{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -763,7 +763,7 @@ func TestDashboardService_FindDashboardCellView(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.GetDashboardCellView(ctx, 1, 1) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/label_test.go b/authorizer/label_test.go index da703371b14..a03173dd889 100644 --- a/authorizer/label_test.go +++ b/authorizer/label_test.go @@ -125,7 +125,7 @@ func TestLabelService_FindLabelByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindLabelByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -280,7 +280,7 @@ func TestLabelService_FindLabels(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) labels, err := s.FindLabels(ctx, influxdb.LabelFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(labels, tt.wants.labels, labelCmpOptions...); diff != "" { t.Errorf("labels are different -got/+want\ndiff %s", diff) @@ -388,7 +388,7 @@ func TestLabelService_UpdateLabel(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateLabel(ctx, tt.args.id, influxdb.LabelUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -488,7 +488,7 @@ func TestLabelService_DeleteLabel(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteLabel(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -592,7 +592,7 @@ func TestLabelService_CreateLabel(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateLabel(ctx, &influxdb.Label{Name: "name", OrgID: orgOneInfluxID}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -824,7 +824,7 @@ func TestLabelService_FindResourceLabels(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) labels, err := s.FindResourceLabels(ctx, tt.args.filter) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(labels, tt.wants.labels, labelCmpOptions...); diff != "" { t.Errorf("labels are different -got/+want\ndiff %s", diff) @@ -976,7 +976,7 @@ func TestLabelService_CreateLabelMapping(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.CreateLabelMapping(ctx, &tt.args.mapping) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -1124,7 +1124,7 @@ func TestLabelService_DeleteLabelMapping(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteLabelMapping(ctx, &tt.args.mapping) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/notification_endpoint_test.go b/authorizer/notification_endpoint_test.go index 4d16ac5777f..04fb3b098c5 100644 --- a/authorizer/notification_endpoint_test.go +++ b/authorizer/notification_endpoint_test.go @@ -119,7 +119,7 @@ func TestNotificationEndpointService_FindNotificationEndpointByID(t *testing.T) ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindNotificationEndpointByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -203,7 +203,7 @@ func TestNotificationEndpointService_FindNotificationEndpoints(t *testing.T) { oid := platform.ID(10) edps, _, err := s.FindNotificationEndpoints(ctx, influxdb.NotificationEndpointFilter{OrgID: &oid}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(edps, tt.wants.notificationEndpoints, notificationEndpointCmpOptions...); diff != "" { t.Errorf("notificationEndpoints are different -got/+want\ndiff %s", diff) @@ -328,7 +328,7 @@ func TestNotificationEndpointService_UpdateNotificationEndpoint(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateNotificationEndpoint(ctx, tt.args.id, &endpoint.Slack{}, platform.ID(1)) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -448,7 +448,7 @@ func TestNotificationEndpointService_PatchNotificationEndpoint(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.PatchNotificationEndpoint(ctx, tt.args.id, influxdb.NotificationEndpointUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -559,7 +559,7 @@ func TestNotificationEndpointService_DeleteNotificationEndpoint(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, _, err := s.DeleteNotificationEndpoint(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -669,7 +669,7 @@ func TestNotificationEndpointService_CreateNotificationEndpoint(t *testing.T) { Base: endpoint.Base{ OrgID: idPtr(tt.args.orgID)}, }, platform.ID(1)) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/notification_rule_test.go b/authorizer/notification_rule_test.go index 779a55139ad..adb1b2818b5 100644 --- a/authorizer/notification_rule_test.go +++ b/authorizer/notification_rule_test.go @@ -117,7 +117,7 @@ func TestNotificationRuleStore_FindNotificationRuleByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindNotificationRuleByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -263,7 +263,7 @@ func TestNotificationRuleStore_FindNotificationRules(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) ts, _, err := s.FindNotificationRules(ctx, influxdb.NotificationRuleFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(ts, tt.wants.notificationRules, notificationRuleCmpOptions...); diff != "" { t.Errorf("notificationRules are different -got/+want\ndiff %s", diff) @@ -391,7 +391,7 @@ func TestNotificationRuleStore_UpdateNotificationRule(t *testing.T) { } _, err := s.UpdateNotificationRule(ctx, tt.args.id, nrc, platform.ID(1)) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -510,7 +510,7 @@ func TestNotificationRuleStore_PatchNotificationRule(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.PatchNotificationRule(ctx, tt.args.id, influxdb.NotificationRuleUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -619,7 +619,7 @@ func TestNotificationRuleStore_DeleteNotificationRule(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteNotificationRule(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -711,7 +711,7 @@ func TestNotificationRuleStore_CreateNotificationRule(t *testing.T) { } err := s.CreateNotificationRule(ctx, nrc, platform.ID(1)) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/org_test.go b/authorizer/org_test.go index 3ebb2a172a3..e5ea7785f5c 100644 --- a/authorizer/org_test.go +++ b/authorizer/org_test.go @@ -109,7 +109,7 @@ func TestOrgService_FindOrganizationByID(t *testing.T) { ctx := context.Background() ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindOrganizationByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -192,7 +192,7 @@ func TestOrgService_FindOrganization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindOrganization(ctx, influxdb.OrganizationFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -302,7 +302,7 @@ func TestOrgService_FindOrganizations(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) orgs, _, err := s.FindOrganizations(ctx, influxdb.OrganizationFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(orgs, tt.wants.orgs, orgCmpOptions...); diff != "" { t.Errorf("organizations are different -got/+want\ndiff %s", diff) @@ -392,7 +392,7 @@ func TestOrgService_UpdateOrganization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.UpdateOrganization(ctx, tt.args.id, influxdb.OrganizationUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -474,7 +474,7 @@ func TestOrgService_DeleteOrganization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.DeleteOrganization(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -552,7 +552,7 @@ func TestOrgService_CreateOrganization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateOrganization(ctx, &influxdb.Organization{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/scraper_test.go b/authorizer/scraper_test.go index af93a483192..18dca984b91 100644 --- a/authorizer/scraper_test.go +++ b/authorizer/scraper_test.go @@ -112,7 +112,7 @@ func TestScraperTargetStoreService_GetTargetByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.GetTargetByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -237,7 +237,7 @@ func TestScraperTargetStoreService_ListTargets(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) ts, err := s.ListTargets(ctx, influxdb.ScraperTargetFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(ts, tt.wants.scrapers, scraperCmpOptions...); diff != "" { t.Errorf("scrapers are different -got/+want\ndiff %s", diff) @@ -407,7 +407,7 @@ func TestScraperTargetStoreService_UpdateTarget(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateTarget(ctx, &influxdb.ScraperTarget{ID: tt.args.id, BucketID: tt.args.bucketID}, platform.ID(1)) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -513,7 +513,7 @@ func TestScraperTargetStoreService_RemoveTarget(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.RemoveTarget(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -653,7 +653,7 @@ func TestScraperTargetStoreService_AddTarget(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.AddTarget(ctx, &influxdb.ScraperTarget{OrgID: tt.args.orgID, BucketID: tt.args.bucketID}, platform.ID(1)) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/secret_test.go b/authorizer/secret_test.go index d981c81b405..cca5f09093d 100644 --- a/authorizer/secret_test.go +++ b/authorizer/secret_test.go @@ -146,7 +146,7 @@ func TestSecretService_LoadSecret(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.LoadSecret(ctx, tt.args.org, tt.args.key) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -272,7 +272,7 @@ func TestSecretService_GetSecretKeys(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) secrets, err := s.GetSecretKeys(ctx, tt.args.org) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(secrets, tt.wants.secrets, secretCmpOptions...); diff != "" { t.Errorf("secrets are different -got/+want\ndiff %s", diff) @@ -363,7 +363,7 @@ func TestSecretService_PatchSecrets(t *testing.T) { patches := make(map[string]string) err := s.PatchSecrets(ctx, tt.args.org, patches) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -449,7 +449,7 @@ func TestSecretService_DeleteSecret(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteSecret(ctx, tt.args.org) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -531,7 +531,7 @@ func TestSecretService_PutSecret(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.PutSecret(ctx, tt.args.orgID, "", "") - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -694,7 +694,7 @@ func TestSecretService_PutSecrets(t *testing.T) { secrets := make(map[string]string) err := s.PutSecrets(ctx, tt.args.orgID, secrets) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/source_test.go b/authorizer/source_test.go index 83916ab15bd..2a41608cf04 100644 --- a/authorizer/source_test.go +++ b/authorizer/source_test.go @@ -109,7 +109,7 @@ func TestSourceService_DefaultSource(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.DefaultSource(ctx) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -197,7 +197,7 @@ func TestSourceService_FindSourceByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindSourceByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -321,7 +321,7 @@ func TestSourceService_FindSources(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) sources, _, err := s.FindSources(ctx, influxdb.DefaultSourceFindOptions) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(sources, tt.wants.sources, sourceCmpOptions...); diff != "" { t.Errorf("sources are different -got/+want\ndiff %s", diff) @@ -436,7 +436,7 @@ func TestSourceService_UpdateSource(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateSource(ctx, tt.args.id, influxdb.SourceUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -541,7 +541,7 @@ func TestSourceService_DeleteSource(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteSource(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -623,7 +623,7 @@ func TestSourceService_CreateSource(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateSource(ctx, &influxdb.Source{OrganizationID: tt.args.orgID}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/telegraf_test.go b/authorizer/telegraf_test.go index 2b1d20a6226..85581e19d82 100644 --- a/authorizer/telegraf_test.go +++ b/authorizer/telegraf_test.go @@ -112,7 +112,7 @@ func TestTelegrafConfigStore_FindTelegrafConfigByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindTelegrafConfigByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -236,7 +236,7 @@ func TestTelegrafConfigStore_FindTelegrafConfigs(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) ts, _, err := s.FindTelegrafConfigs(ctx, influxdb.TelegrafConfigFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(ts, tt.wants.telegrafs, telegrafCmpOptions...); diff != "" { t.Errorf("telegrafs are different -got/+want\ndiff %s", diff) @@ -351,7 +351,7 @@ func TestTelegrafConfigStore_UpdateTelegrafConfig(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateTelegrafConfig(ctx, tt.args.id, &influxdb.TelegrafConfig{}, platform.ID(1)) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -456,7 +456,7 @@ func TestTelegrafConfigStore_DeleteTelegrafConfig(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteTelegrafConfig(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -538,7 +538,7 @@ func TestTelegrafConfigStore_CreateTelegrafConfig(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateTelegrafConfig(ctx, &influxdb.TelegrafConfig{OrgID: tt.args.orgID}, platform.ID(1)) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/urm_test.go b/authorizer/urm_test.go index 69d8e10b5bf..8d2152fde3e 100644 --- a/authorizer/urm_test.go +++ b/authorizer/urm_test.go @@ -136,7 +136,7 @@ func TestURMService_FindUserResourceMappings(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) urms, _, err := s.FindUserResourceMappings(ctx, influxdb.UserResourceMappingFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(urms, tt.wants.urms); diff != "" { t.Errorf("urms are different -got/+want\ndiff %s", diff) @@ -247,12 +247,12 @@ func TestURMService_WriteUserResourceMapping(t *testing.T) { t.Run("create urm", func(t *testing.T) { err := s.CreateUserResourceMapping(ctx, &influxdb.UserResourceMapping{ResourceType: influxdb.BucketsResourceType, ResourceID: 1}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) t.Run("delete urm", func(t *testing.T) { err := s.DeleteUserResourceMapping(ctx, 1, 100) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) }) diff --git a/authorizer/user_test.go b/authorizer/user_test.go index 89c5385862b..f960adfa916 100644 --- a/authorizer/user_test.go +++ b/authorizer/user_test.go @@ -110,7 +110,7 @@ func TestUserService_FindUserByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindUserByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -193,7 +193,7 @@ func TestUserService_FindUser(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindUser(ctx, influxdb.UserFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -303,7 +303,7 @@ func TestUserService_FindUsers(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) users, _, err := s.FindUsers(ctx, influxdb.UserFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(users, tt.wants.users, userCmpOptions...); diff != "" { t.Errorf("users are different -got/+want\ndiff %s", diff) @@ -393,7 +393,7 @@ func TestUserService_UpdateUser(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.UpdateUser(ctx, tt.args.id, influxdb.UserUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -475,7 +475,7 @@ func TestUserService_DeleteUser(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.DeleteUser(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -553,7 +553,7 @@ func TestUserService_CreateUser(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateUser(ctx, &influxdb.User{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/authorizer/variable_test.go b/authorizer/variable_test.go index d67967b2b40..dbde4ee8497 100644 --- a/authorizer/variable_test.go +++ b/authorizer/variable_test.go @@ -112,7 +112,7 @@ func TestVariableService_FindVariableByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindVariableByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -236,7 +236,7 @@ func TestVariableService_FindVariables(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) variables, err := s.FindVariables(ctx, influxdb.VariableFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(variables, tt.wants.variables, variableCmpOptions...); diff != "" { t.Errorf("variables are different -got/+want\ndiff %s", diff) @@ -351,7 +351,7 @@ func TestVariableService_UpdateVariable(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateVariable(ctx, tt.args.id, &influxdb.VariableUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -463,7 +463,7 @@ func TestVariableService_ReplaceVariable(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.ReplaceVariable(ctx, &tt.args.variable) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -568,7 +568,7 @@ func TestVariableService_DeleteVariable(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteVariable(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -650,7 +650,7 @@ func TestVariableService_CreateVariable(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateVariable(ctx, &influxdb.Variable{OrganizationID: tt.args.orgID}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/dbrp/middleware_auth_test.go b/dbrp/middleware_auth_test.go index a979c269ff3..7ba4464bdf3 100644 --- a/dbrp/middleware_auth_test.go +++ b/dbrp/middleware_auth_test.go @@ -157,7 +157,7 @@ func TestAuth_FindByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindByID(ctx, tt.args.orgID, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -377,7 +377,7 @@ func TestAuth_FindMany(t *testing.T) { if ngots != len(gots) { t.Errorf("got wrong number back") } - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(tt.wants.ms, gots, influxdbtesting.DBRPMappingCmpOptions...); diff != "" { t.Errorf("unexpected result -want/+got:\n\t%s", diff) } @@ -464,7 +464,7 @@ func TestAuth_Create(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.Create(ctx, &tt.args.m) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -542,7 +542,7 @@ func TestAuth_Update(t *testing.T) { // Does not matter how we update, we only need to check auth. err := s.Update(ctx, &influxdb.DBRPMapping{ID: tt.args.id, OrganizationID: tt.args.orgID, BucketID: 1}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -633,7 +633,7 @@ func TestAuth_Delete(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.Delete(ctx, tt.args.orgID, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/label/middleware_auth_test.go b/label/middleware_auth_test.go index 38a43a9d2e9..64adc9ac2fd 100644 --- a/label/middleware_auth_test.go +++ b/label/middleware_auth_test.go @@ -124,7 +124,7 @@ func TestLabelService_FindLabelByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindLabelByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -279,7 +279,7 @@ func TestLabelService_FindLabels(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) labels, err := s.FindLabels(ctx, influxdb.LabelFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(labels, tt.wants.labels, labelCmpOptions...); diff != "" { t.Errorf("labels are different -got/+want\ndiff %s", diff) @@ -387,7 +387,7 @@ func TestLabelService_UpdateLabel(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateLabel(ctx, tt.args.id, influxdb.LabelUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -487,7 +487,7 @@ func TestLabelService_DeleteLabel(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteLabel(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -591,7 +591,7 @@ func TestLabelService_CreateLabel(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateLabel(ctx, &influxdb.Label{Name: "name", OrgID: orgOneInfluxID}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -823,7 +823,7 @@ func TestLabelService_FindResourceLabels(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) labels, err := s.FindResourceLabels(ctx, tt.args.filter) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(labels, tt.wants.labels, labelCmpOptions...); diff != "" { t.Errorf("labels are different -got/+want\ndiff %s", diff) @@ -975,7 +975,7 @@ func TestLabelService_CreateLabelMapping(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.CreateLabelMapping(ctx, &tt.args.mapping) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -1123,7 +1123,7 @@ func TestLabelService_DeleteLabelMapping(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteLabelMapping(ctx, &tt.args.mapping) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/notification/check/check_test.go b/notification/check/check_test.go index 0da5fafbf27..22a7dd1306d 100644 --- a/notification/check/check_test.go +++ b/notification/check/check_test.go @@ -147,7 +147,7 @@ func TestValidCheck(t *testing.T) { } for _, c := range cases { got := c.src.Valid(fluxlang.DefaultService) - influxTesting.ErrorsEqual(t, got, c.err, false) + influxTesting.ErrorsEqual(t, got, c.err) } } diff --git a/notification/endpoint/endpoint_test.go b/notification/endpoint/endpoint_test.go index cfbb35157c4..1b44bf71c46 100644 --- a/notification/endpoint/endpoint_test.go +++ b/notification/endpoint/endpoint_test.go @@ -207,7 +207,7 @@ func TestValidEndpoint(t *testing.T) { } else { exp = c.err } - influxTesting.ErrorsEqual(t, got, exp, false) + influxTesting.ErrorsEqual(t, got, exp) }) } } diff --git a/notification/rule/rule_test.go b/notification/rule/rule_test.go index 90a21b99438..0a8463e2a42 100644 --- a/notification/rule/rule_test.go +++ b/notification/rule/rule_test.go @@ -200,7 +200,7 @@ func TestValidRule(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { got := c.src.Valid() - influxTesting.ErrorsEqual(t, got, c.err, false) + influxTesting.ErrorsEqual(t, got, c.err) }) } } diff --git a/notification/rule/telegram_test.go b/notification/rule/telegram_test.go index decca9de4d1..86552dc55f6 100644 --- a/notification/rule/telegram_test.go +++ b/notification/rule/telegram_test.go @@ -310,7 +310,7 @@ func TestTelegram_Valid(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { got := c.rule.Valid() - influxTesting.ErrorsEqual(t, got, c.err, false) + influxTesting.ErrorsEqual(t, got, c.err) }) } diff --git a/predicate/parser_test.go b/predicate/parser_test.go index a0b509413cc..164f1bec19b 100644 --- a/predicate/parser_test.go +++ b/predicate/parser_test.go @@ -81,7 +81,7 @@ func TestParseNode(t *testing.T) { } for _, c := range cases { node, err := Parse(c.str) - influxtesting.ErrorsEqual(t, err, c.err, false) + influxtesting.ErrorsEqual(t, err, c.err) if c.err == nil { if diff := cmp.Diff(node, c.node); diff != "" { t.Errorf("tag rule mismatch:\n %s", diff) @@ -158,7 +158,7 @@ func TestParseTagRule(t *testing.T) { p := new(parser) p.sc = influxql.NewScanner(strings.NewReader(c.str)) tr, err := p.parseTagRuleNode() - influxtesting.ErrorsEqual(t, err, c.err, false) + influxtesting.ErrorsEqual(t, err, c.err) if c.err == nil { if diff := cmp.Diff(tr, c.node); diff != "" { t.Errorf("tag rule mismatch:\n %s", diff) diff --git a/predicate/predicate_test.go b/predicate/predicate_test.go index 69240e907cb..413d1e7869d 100644 --- a/predicate/predicate_test.go +++ b/predicate/predicate_test.go @@ -341,7 +341,7 @@ func TestDataTypeConversion(t *testing.T) { for _, c := range cases { if c.node != nil { dataType, err := c.node.ToDataType() - influxtesting.ErrorsEqual(t, err, c.err, false) + influxtesting.ErrorsEqual(t, err, c.err) if c.err != nil { continue } diff --git a/secret/middleware_auth_test.go b/secret/middleware_auth_test.go index f5cc88e153f..e45c2ba01c5 100644 --- a/secret/middleware_auth_test.go +++ b/secret/middleware_auth_test.go @@ -146,7 +146,7 @@ func TestSecretService_LoadSecret(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.LoadSecret(ctx, tt.args.org, tt.args.key) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -272,7 +272,7 @@ func TestSecretService_GetSecretKeys(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) secrets, err := s.GetSecretKeys(ctx, tt.args.org) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(secrets, tt.wants.secrets, secretCmpOptions...); diff != "" { t.Errorf("secrets are different -got/+want\ndiff %s", diff) @@ -363,7 +363,7 @@ func TestSecretService_PatchSecrets(t *testing.T) { patches := make(map[string]string) err := s.PatchSecrets(ctx, tt.args.org, patches) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -449,7 +449,7 @@ func TestSecretService_DeleteSecret(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteSecret(ctx, tt.args.org) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -531,7 +531,7 @@ func TestSecretService_PutSecret(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.PutSecret(ctx, tt.args.orgID, "", "") - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -694,7 +694,7 @@ func TestSecretService_PutSecrets(t *testing.T) { secrets := make(map[string]string) err := s.PutSecrets(ctx, tt.args.orgID, secrets) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/tag_test.go b/tag_test.go index 9898fd47f5f..919331405d1 100644 --- a/tag_test.go +++ b/tag_test.go @@ -63,6 +63,6 @@ func TestTagValid(t *testing.T) { } for _, c := range cases { err := c.src.Valid() - influxTesting.ErrorsEqual(t, err, c.err, false) + influxTesting.ErrorsEqual(t, err, c.err) } } diff --git a/tenant/http_server_bucket_test.go b/tenant/http_server_bucket_test.go index 91be98f0179..5cf8628d7ea 100644 --- a/tenant/http_server_bucket_test.go +++ b/tenant/http_server_bucket_test.go @@ -200,7 +200,7 @@ func TestHTTPBucketService_InvalidRetention(t *testing.T) { upd.Description = tt.args.description bucket, err := s.UpdateBucket(ctx, tt.args.id, upd) - itesting.ErrorsEqual(t, err, tt.wants.err, false) + itesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(bucket, tt.wants.bucket, bucketCmpOptions...); diff != "" { t.Errorf("bucket is different -got/+want\ndiff %s", diff) diff --git a/tenant/http_server_org_test.go b/tenant/http_server_org_test.go index af56ab9e8b5..9821038c376 100644 --- a/tenant/http_server_org_test.go +++ b/tenant/http_server_org_test.go @@ -55,5 +55,5 @@ func initHttpOrgService(f itesting.OrganizationFields, t *testing.T) (influxdb.O } func TestHTTPOrgService(t *testing.T) { - itesting.OrganizationService(initHttpOrgService, t) + itesting.OrganizationService(initHttpOrgService, true, t) } diff --git a/tenant/http_server_user_test.go b/tenant/http_server_user_test.go index 325395d534a..709759857e9 100644 --- a/tenant/http_server_user_test.go +++ b/tenant/http_server_user_test.go @@ -48,5 +48,5 @@ func initHttpUserService(f platformtesting.UserFields, t *testing.T) (platform.U func TestUserService(t *testing.T) { t.Parallel() - platformtesting.UserService(initHttpUserService, t) + platformtesting.UserService(initHttpUserService, true, t) } diff --git a/tenant/middleware_bucket_auth_test.go b/tenant/middleware_bucket_auth_test.go index 97e2b29d37e..2f7ed918d99 100644 --- a/tenant/middleware_bucket_auth_test.go +++ b/tenant/middleware_bucket_auth_test.go @@ -112,7 +112,7 @@ func TestBucketService_FindBucketByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindBucketByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -197,7 +197,7 @@ func TestBucketService_FindBucket(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindBucket(ctx, influxdb.BucketFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -322,7 +322,7 @@ func TestBucketService_FindBuckets(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) buckets, _, err := s.FindBuckets(ctx, influxdb.BucketFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(buckets, tt.wants.buckets, bucketCmpOptions...); diff != "" { t.Errorf("buckets are different -got/+want\ndiff %s", diff) @@ -437,7 +437,7 @@ func TestBucketService_UpdateBucket(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) _, err := s.UpdateBucket(ctx, tt.args.id, influxdb.BucketUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -542,7 +542,7 @@ func TestBucketService_DeleteBucket(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) err := s.DeleteBucket(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -624,7 +624,7 @@ func TestBucketService_CreateBucket(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateBucket(ctx, &influxdb.Bucket{OrgID: tt.args.orgID}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/tenant/middleware_org_auth_test.go b/tenant/middleware_org_auth_test.go index 2498ad4fe1a..5907c6b8f03 100644 --- a/tenant/middleware_org_auth_test.go +++ b/tenant/middleware_org_auth_test.go @@ -110,7 +110,7 @@ func TestOrgService_FindOrganizationByID(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindOrganizationByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -193,7 +193,7 @@ func TestOrgService_FindOrganization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindOrganization(ctx, influxdb.OrganizationFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -303,7 +303,7 @@ func TestOrgService_FindOrganizations(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) orgs, _, err := s.FindOrganizations(ctx, influxdb.OrganizationFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(orgs, tt.wants.orgs, orgCmpOptions...); diff != "" { t.Errorf("organizations are different -got/+want\ndiff %s", diff) @@ -393,7 +393,7 @@ func TestOrgService_UpdateOrganization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.UpdateOrganization(ctx, tt.args.id, influxdb.OrganizationUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -475,7 +475,7 @@ func TestOrgService_DeleteOrganization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.DeleteOrganization(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -553,7 +553,7 @@ func TestOrgService_CreateOrganization(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateOrganization(ctx, &influxdb.Organization{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/tenant/middleware_org_logging_test.go b/tenant/middleware_org_logging_test.go index ede755bf0ff..648dd046af3 100644 --- a/tenant/middleware_org_logging_test.go +++ b/tenant/middleware_org_logging_test.go @@ -10,7 +10,7 @@ import ( ) func TestOrganizationLoggingService(t *testing.T) { - influxdbtesting.OrganizationService(initBoltOrganizationLoggingService, t) + influxdbtesting.OrganizationService(initBoltOrganizationLoggingService, false, t) } func initBoltOrganizationLoggingService(f influxdbtesting.OrganizationFields, t *testing.T) (influxdb.OrganizationService, string, func()) { diff --git a/tenant/middleware_urm_auth_test.go b/tenant/middleware_urm_auth_test.go index bc1f2510ed3..5e51e089d66 100644 --- a/tenant/middleware_urm_auth_test.go +++ b/tenant/middleware_urm_auth_test.go @@ -164,7 +164,7 @@ func TestURMService_FindUserResourceMappings(t *testing.T) { )) urms, _, err := s.FindUserResourceMappings(ctx, influxdb.UserResourceMappingFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(urms, tt.wants.urms); diff != "" { t.Errorf("urms are different -got/+want\ndiff %s", diff) @@ -266,7 +266,7 @@ func TestURMService_FindUserResourceMappingsBucketAuth(t *testing.T) { ctx = influxdbcontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, tt.args.permissions)) urms, _, err := s.FindUserResourceMappings(ctx, influxdb.UserResourceMappingFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(urms, tt.wants.urms); diff != "" { t.Errorf("urms are different -got/+want\ndiff %s", diff) @@ -376,12 +376,12 @@ func TestURMService_WriteUserResourceMapping(t *testing.T) { t.Run("create urm", func(t *testing.T) { err := s.CreateUserResourceMapping(ctx, &influxdb.UserResourceMapping{ResourceType: influxdb.BucketsResourceType, ResourceID: 1}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) t.Run("delete urm", func(t *testing.T) { err := s.DeleteUserResourceMapping(ctx, 1, 100) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) }) diff --git a/tenant/middleware_user_auth_test.go b/tenant/middleware_user_auth_test.go index 35f8bf11221..8d71b8f3157 100644 --- a/tenant/middleware_user_auth_test.go +++ b/tenant/middleware_user_auth_test.go @@ -112,7 +112,7 @@ func TestUserService_FindUserByID(t *testing.T) { ctx = icontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindUserByID(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -195,7 +195,7 @@ func TestUserService_FindUser(t *testing.T) { ctx = icontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.FindUser(ctx, influxdb.UserFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -305,7 +305,7 @@ func TestUserService_FindUsers(t *testing.T) { ctx = icontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) users, _, err := s.FindUsers(ctx, influxdb.UserFilter{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) if diff := cmp.Diff(users, tt.wants.users, userCmpOptions...); diff != "" { t.Errorf("users are different -got/+want\ndiff %s", diff) @@ -395,7 +395,7 @@ func TestUserService_UpdateUser(t *testing.T) { ctx = icontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) _, err := s.UpdateUser(ctx, tt.args.id, influxdb.UserUpdate{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -477,7 +477,7 @@ func TestUserService_DeleteUser(t *testing.T) { ctx = icontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.DeleteUser(ctx, tt.args.id) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } @@ -555,7 +555,7 @@ func TestUserService_CreateUser(t *testing.T) { ctx = icontext.SetAuthorizer(ctx, mock.NewMockAuthorizer(false, []influxdb.Permission{tt.args.permission})) err := s.CreateUser(ctx, &influxdb.User{}) - influxdbtesting.ErrorsEqual(t, err, tt.wants.err, false) + influxdbtesting.ErrorsEqual(t, err, tt.wants.err) }) } } diff --git a/tenant/middleware_user_logging_test.go b/tenant/middleware_user_logging_test.go index 6ea0e24091b..2e1fd8b5348 100644 --- a/tenant/middleware_user_logging_test.go +++ b/tenant/middleware_user_logging_test.go @@ -10,7 +10,7 @@ import ( ) func TestUserLoggingService(t *testing.T) { - influxdbtesting.UserService(initBoltUserLoggingService, t) + influxdbtesting.UserService(initBoltUserLoggingService, false, t) } func initBoltUserLoggingService(f influxdbtesting.UserFields, t *testing.T) (influxdb.UserService, string, func()) { diff --git a/tenant/service_org_test.go b/tenant/service_org_test.go index 5d90aaba124..fa6bcc5d236 100644 --- a/tenant/service_org_test.go +++ b/tenant/service_org_test.go @@ -11,7 +11,7 @@ import ( ) func TestBoltOrganizationService(t *testing.T) { - influxdbtesting.OrganizationService(initBoltOrganizationService, t) + influxdbtesting.OrganizationService(initBoltOrganizationService, false, t) } func initBoltOrganizationService(f influxdbtesting.OrganizationFields, t *testing.T) (influxdb.OrganizationService, string, func()) { diff --git a/tenant/service_user_test.go b/tenant/service_user_test.go index a1106083ec9..a6b2f8bbc92 100644 --- a/tenant/service_user_test.go +++ b/tenant/service_user_test.go @@ -13,7 +13,7 @@ import ( ) func TestBoltUserService(t *testing.T) { - influxdbtesting.UserService(initBoltUserService, t) + influxdbtesting.UserService(initBoltUserService, false, t) } func initBoltUserService(f influxdbtesting.UserFields, t *testing.T) (influxdb.UserService, string, func()) { diff --git a/testing/auth.go b/testing/auth.go index 722846eb172..d1badb8cbc4 100644 --- a/testing/auth.go +++ b/testing/auth.go @@ -324,7 +324,7 @@ func CreateAuthorization( t.Fatalf("expected error '%v' got '%v'", tt.wants.err, err) } - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) defer s.DeleteAuthorization(ctx, tt.args.authorization.ID) @@ -422,7 +422,7 @@ func FindAuthorizationByID( for i := range tt.fields.Authorizations { authorization, err := s.FindAuthorizationByID(ctx, tt.fields.Authorizations[i].ID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(authorization, tt.wants.authorizations[i], authorizationCmpOptions...); diff != "" { t.Errorf("authorization is different -got/+want\ndiff %s", diff) @@ -675,7 +675,7 @@ func UpdateAuthorization( ctx := context.Background() updatedAuth, err := s.UpdateAuthorization(ctx, tt.args.id, tt.args.upd) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if tt.wants.err == nil { authorization, err := s.FindAuthorizationByID(ctx, tt.args.id) @@ -853,7 +853,7 @@ func FindAuthorizationByToken( ctx := context.Background() authorization, err := s.FindAuthorizationByToken(ctx, tt.args.token) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(authorization, tt.wants.authorization, authorizationCmpOptions...); diff != "" { t.Errorf("authorization is different -got/+want\ndiff %s", diff) @@ -1177,7 +1177,7 @@ func FindAuthorizations( } authorizations, _, err := s.FindAuthorizations(ctx, filter) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(authorizations, tt.wants.authorizations, authorizationCmpOptions...); diff != "" { t.Errorf("authorizations are different -got/+want\ndiff %s", diff) } @@ -1329,7 +1329,7 @@ func DeleteAuthorization( defer done() ctx := context.Background() err := s.DeleteAuthorization(ctx, tt.args.ID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) filter := influxdb.AuthorizationFilter{} authorizations, _, err := s.FindAuthorizations(ctx, filter) diff --git a/testing/bucket_service.go b/testing/bucket_service.go index ea12d0a1d5f..fcdb5970b57 100644 --- a/testing/bucket_service.go +++ b/testing/bucket_service.go @@ -379,7 +379,7 @@ func CreateBucket( defer done() ctx := context.Background() err := s.CreateBucket(ctx, tt.args.bucket) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) // Delete only newly created buckets - ie., with a not nil ID // if tt.args.bucket.ID.Valid() { @@ -505,7 +505,7 @@ func FindBucketByID( ctx := context.Background() bucket, err := s.FindBucketByID(ctx, tt.args.id) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(bucket, tt.wants.bucket, bucketCmpOptions...); diff != "" { t.Errorf("bucket is different -got/+want\ndiff %s", diff) @@ -907,7 +907,7 @@ func FindBuckets( } buckets, _, err := s.FindBuckets(ctx, filter, tt.args.findOptions) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) // remove system buckets filteredBuckets := []*influxdb.Bucket{} @@ -1074,7 +1074,7 @@ func DeleteBucket( defer done() ctx := context.Background() err := s.DeleteBucket(ctx, tt.args.ID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) filter := influxdb.BucketFilter{} buckets, _, err := s.FindBuckets(ctx, filter) @@ -1243,7 +1243,7 @@ func FindBucket( } bucket, err := s.FindBucket(ctx, filter) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(bucket, tt.wants.bucket, bucketCmpOptions...); diff != "" { t.Errorf("buckets are different -got/+want\ndiff %s", diff) @@ -1738,7 +1738,7 @@ func UpdateBucket( upd.Description = tt.args.description bucket, err := s.UpdateBucket(ctx, tt.args.id, upd) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(bucket, tt.wants.bucket, bucketCmpOptions...); diff != "" { t.Errorf("bucket is different -got/+want\ndiff %s", diff) diff --git a/testing/label_service.go b/testing/label_service.go index d3ec3f114f2..5fca8054ea6 100644 --- a/testing/label_service.go +++ b/testing/label_service.go @@ -275,7 +275,7 @@ func CreateLabel( defer done() ctx := context.Background() err := s.CreateLabel(ctx, tt.args.label) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) defer s.DeleteLabel(ctx, tt.args.label.ID) @@ -414,7 +414,7 @@ func FindLabels( defer done() ctx := context.Background() labels, err := s.FindLabels(ctx, tt.args.filter) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(labels, tt.wants.labels, labelCmpOptions...); diff != "" { t.Errorf("labels are different -got/+want\ndiff %s", diff) @@ -492,7 +492,7 @@ func FindLabelByID( defer done() ctx := context.Background() label, err := s.FindLabelByID(ctx, tt.args.id) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(label, tt.wants.label, labelCmpOptions...); diff != "" { t.Errorf("labels are different -got/+want\ndiff %s", diff) @@ -766,7 +766,7 @@ func UpdateLabel( defer done() ctx := context.Background() _, err := s.UpdateLabel(ctx, tt.args.labelID, tt.args.update) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) labels, err := s.FindLabels(ctx, influxdb.LabelFilter{}) if err != nil { @@ -863,7 +863,7 @@ func DeleteLabel( defer done() ctx := context.Background() err := s.DeleteLabel(ctx, tt.args.labelID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) labels, err := s.FindLabels(ctx, influxdb.LabelFilter{}) if err != nil { @@ -953,7 +953,7 @@ func CreateLabelMapping( defer done() ctx := context.Background() err := s.CreateLabelMapping(ctx, tt.args.mapping) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) defer s.DeleteLabelMapping(ctx, tt.args.mapping) @@ -1029,7 +1029,7 @@ func DeleteLabelMapping( defer done() ctx := context.Background() err := s.DeleteLabelMapping(ctx, tt.args.mapping) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) labels, err := s.FindResourceLabels(ctx, tt.args.filter) if err != nil { diff --git a/testing/organization_service.go b/testing/organization_service.go index 73a4d702177..da10bf6d862 100644 --- a/testing/organization_service.go +++ b/testing/organization_service.go @@ -49,12 +49,11 @@ type OrganizationFields struct { } // OrganizationService tests all the service functions. -func OrganizationService( - init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), t *testing.T, -) { +func OrganizationService(init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), isInMem bool, t *testing.T) { tests := []struct { name string fn func(init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), + isInMem bool, t *testing.T) }{ { @@ -86,22 +85,19 @@ func OrganizationService( t.Run(tt.name, func(t *testing.T) { tt := tt t.Parallel() - tt.fn(init, t) + tt.fn(init, isInMem, t) }) } } // CreateOrganization testing -func CreateOrganization( - init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), - t *testing.T, -) { +func CreateOrganization(init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), isInMem bool, t *testing.T) { type args struct { organization *influxdb.Organization } type wants struct { err error - errOptional bool + inMemNoError bool organizations []*influxdb.Organization } @@ -202,8 +198,8 @@ func CreateOrganization( Name: "organization1", }, }, - err: &errors.Error{Code: errors.ETooLarge, Err: bolt.ErrKeyTooLarge}, - errOptional: true, + err: &errors.Error{Code: errors.ETooLarge, Err: bolt.ErrKeyTooLarge}, + inMemNoError: true, }, }, { @@ -339,19 +335,19 @@ func CreateOrganization( defer done() ctx := context.Background() errCreate := s.CreateOrganization(ctx, tt.args.organization) - diffPlatformErrors(tt.name, errCreate, tt.wants.err, tt.wants.errOptional, t) + diffPlatformErrors(tt.name, errCreate, tt.wants.err, tt.wants.inMemNoError, isInMem, t) // Delete only newly created organizations // if tt.args.organization.ID != nil { defer s.DeleteOrganization(ctx, tt.args.organization.ID) organizations, _, err := s.FindOrganizations(ctx, influxdb.OrganizationFilter{}) - diffPlatformErrors(tt.name, err, nil, tt.wants.errOptional, t) + diffPlatformErrors(tt.name, err, nil, tt.wants.inMemNoError, false, t) // Our test cases wants list is for the case when the error occurs // If the error does not occur (usually because of the inmem store) // our list of wanted organizations will be wrong. - if tt.wants.errOptional && errCreate == nil { + if tt.wants.inMemNoError && errCreate == nil { return } if diff := cmp.Diff(organizations, tt.wants.organizations, organizationCmpOptions...); diff != "" { @@ -362,10 +358,7 @@ func CreateOrganization( } // FindOrganizationByID testing -func FindOrganizationByID( - init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), - t *testing.T, -) { +func FindOrganizationByID(init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), isInMem bool, t *testing.T) { type args struct { id platform.ID } @@ -441,7 +434,7 @@ func FindOrganizationByID( ctx := context.Background() organization, err := s.FindOrganizationByID(ctx, tt.args.id) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(organization, tt.wants.organization, organizationCmpOptions...); diff != "" { t.Errorf("organization is different -got/+want\ndiff %s", diff) @@ -451,10 +444,7 @@ func FindOrganizationByID( } // FindOrganizations testing -func FindOrganizations( - init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), - t *testing.T, -) { +func FindOrganizations(init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), isInMem bool, t *testing.T) { type args struct { ID platform.ID name string @@ -663,7 +653,7 @@ func FindOrganizations( } organizations, _, err := s.FindOrganizations(ctx, filter, tt.args.findOptions) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(organizations, tt.wants.organizations, organizationCmpOptions...); diff != "" { t.Errorf("organizations are different -got/+want\ndiff %s", diff) @@ -673,10 +663,7 @@ func FindOrganizations( } // DeleteOrganization testing -func DeleteOrganization( - init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), - t *testing.T, -) { +func DeleteOrganization(init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), isInMem bool, t *testing.T) { type args struct { ID platform.ID } @@ -763,11 +750,11 @@ func DeleteOrganization( defer done() ctx := context.Background() err := s.DeleteOrganization(ctx, tt.args.ID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) filter := influxdb.OrganizationFilter{} organizations, _, err := s.FindOrganizations(ctx, filter) - diffPlatformErrors(tt.name, err, nil, false, t) + diffPlatformErrors(tt.name, err, nil, false, false, t) if diff := cmp.Diff(organizations, tt.wants.organizations, organizationCmpOptions...); diff != "" { t.Errorf("organizations are different -got/+want\ndiff %s", diff) @@ -777,10 +764,7 @@ func DeleteOrganization( } // FindOrganization testing -func FindOrganization( - init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), - t *testing.T, -) { +func FindOrganization(init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), isInMem bool, t *testing.T) { type args struct { name string id platform.ID @@ -895,7 +879,7 @@ func FindOrganization( } organization, err := s.FindOrganization(ctx, filter) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(organization, tt.wants.organization, organizationCmpOptions...); diff != "" { t.Errorf("organizations are different -got/+want\ndiff %s", diff) @@ -905,10 +889,7 @@ func FindOrganization( } // UpdateOrganization testing -func UpdateOrganization( - init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), - t *testing.T, -) { +func UpdateOrganization(init func(OrganizationFields, *testing.T) (influxdb.OrganizationService, string, func()), isInMem bool, t *testing.T) { type args struct { id platform.ID name *string @@ -1134,7 +1115,7 @@ func UpdateOrganization( upd.Description = tt.args.description organization, err := s.UpdateOrganization(ctx, tt.args.id, upd) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(organization, tt.wants.organization, organizationCmpOptions...); diff != "" { t.Errorf("organization is different -got/+want\ndiff %s", diff) diff --git a/testing/scraper_target.go b/testing/scraper_target.go index f14fc519530..52e2c9359e4 100644 --- a/testing/scraper_target.go +++ b/testing/scraper_target.go @@ -304,7 +304,7 @@ func AddTarget( defer done() ctx := context.Background() err := s.AddTarget(ctx, tt.args.target, tt.args.userID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) defer s.RemoveTarget(ctx, tt.args.target.ID) targets, err := s.ListTargets(ctx, influxdb.ScraperTargetFilter{}) @@ -492,7 +492,7 @@ func ListTargets( defer done() ctx := context.Background() targets, err := s.ListTargets(ctx, tt.args.filter) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(targets, tt.wants.targets, targetCmpOptions...); diff != "" { t.Errorf("targets are different -got/+want\ndiff %s", diff) @@ -590,7 +590,7 @@ func GetTargetByID( ctx := context.Background() target, err := s.GetTargetByID(ctx, tt.args.id) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(target, tt.wants.target, targetCmpOptions...); diff != "" { t.Errorf("target is different -got/+want\ndiff %s", diff) @@ -695,7 +695,7 @@ func RemoveTarget(init func(TargetFields, *testing.T) (influxdb.ScraperTargetSto defer done() ctx := context.Background() err := s.RemoveTarget(ctx, tt.args.ID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) targets, err := s.ListTargets(ctx, influxdb.ScraperTargetFilter{}) if err != nil { @@ -836,7 +836,7 @@ func UpdateTarget( } target, err := s.UpdateTarget(ctx, upd, tt.args.userID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(target, tt.wants.target, targetCmpOptions...); diff != "" { t.Errorf("scraper target is different -got/+want\ndiff %s", diff) diff --git a/testing/session.go b/testing/session.go index 17d3e24da1d..2d6cf2d7101 100644 --- a/testing/session.go +++ b/testing/session.go @@ -136,7 +136,7 @@ func CreateSession( defer done() ctx := context.Background() session, err := s.CreateSession(ctx, tt.args.user) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(session, tt.wants.session, sessionCmpOptions...); diff != "" { t.Errorf("sessions are different -got/+want\ndiff %s", diff) @@ -212,7 +212,7 @@ func FindSession( ctx := context.Background() session, err := s.FindSession(ctx, tt.args.key) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(session, tt.wants.session, sessionCmpOptions...); diff != "" { t.Errorf("session is different -got/+want\ndiff %s", diff) @@ -275,7 +275,7 @@ func ExpireSession( ctx := context.Background() err := s.ExpireSession(ctx, tt.args.key) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) session, err := s.FindSession(ctx, tt.args.key) if err.Error() != influxdb.ErrSessionExpired && err.Error() != influxdb.ErrSessionNotFound { @@ -418,7 +418,7 @@ func RenewSession( ctx := context.Background() err := s.RenewSession(ctx, tt.args.session, tt.args.expireAt) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) session, err := s.FindSession(ctx, tt.args.key) if err != nil { diff --git a/testing/source.go b/testing/source.go index 0b85b77ccb6..6151596afe6 100644 --- a/testing/source.go +++ b/testing/source.go @@ -95,7 +95,7 @@ func CreateSource( defer done() ctx := context.Background() err := s.CreateSource(ctx, tt.args.source) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) defer s.DeleteSource(ctx, tt.args.source.ID) sources, _, err := s.FindSources(ctx, platform.FindOptions{}) @@ -178,7 +178,7 @@ func FindSourceByID( defer done() ctx := context.Background() source, err := s.FindSourceByID(ctx, tt.args.id) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(source, tt.wants.source, sourceCmpOptions...); diff != "" { t.Errorf("sources are different -got/+want\ndiff %s", diff) @@ -254,7 +254,7 @@ func FindSources( defer done() ctx := context.Background() sources, _, err := s.FindSources(ctx, tt.args.opts) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(sources, tt.wants.sources, sourceCmpOptions...); diff != "" { t.Errorf("sources are different -got/+want\ndiff %s", diff) @@ -343,7 +343,7 @@ func DeleteSource( defer done() ctx := context.Background() err := s.DeleteSource(ctx, tt.args.id) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) sources, _, err := s.FindSources(ctx, platform.FindOptions{}) if err != nil { diff --git a/testing/user_service.go b/testing/user_service.go index 324c9971ae7..d7c08895b12 100644 --- a/testing/user_service.go +++ b/testing/user_service.go @@ -50,12 +50,11 @@ type UserFields struct { } // UserService tests all the service functions. -func UserService( - init func(UserFields, *testing.T) (influxdb.UserService, string, func()), t *testing.T, -) { +func UserService(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), isInMem bool, t *testing.T) { tests := []struct { name string fn func(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), + isInMem bool, t *testing.T) }{ { @@ -91,23 +90,20 @@ func UserService( t.Run(tt.name, func(t *testing.T) { tt := tt t.Parallel() - tt.fn(init, t) + tt.fn(init, isInMem, t) }) } } // CreateUser testing -func CreateUser( - init func(UserFields, *testing.T) (influxdb.UserService, string, func()), - t *testing.T, -) { +func CreateUser(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), isInMem bool, t *testing.T) { type args struct { user *influxdb.User } type wants struct { - err error - errOptional bool - users []*influxdb.User + err error + inMemNoError bool + users []*influxdb.User } tests := []struct { @@ -243,7 +239,7 @@ func CreateUser( Op: influxdb.OpCreateUser, Err: bolt.ErrKeyTooLarge, }, - errOptional: true, + inMemNoError: true, }, }, } @@ -254,7 +250,7 @@ func CreateUser( defer done() ctx := context.Background() errCreate := s.CreateUser(ctx, tt.args.user) - diffPlatformErrors(tt.name, errCreate, tt.wants.err, tt.wants.errOptional, t) + diffPlatformErrors(tt.name, errCreate, tt.wants.err, tt.wants.inMemNoError, isInMem, t) // Delete only created users - ie., having a not nil ID if tt.args.user.ID.Valid() { defer s.DeleteUser(ctx, tt.args.user.ID) @@ -268,7 +264,7 @@ func CreateUser( // If the operation succeeded against expectations (because is the inmem store) // our wants list will be wrong, so don't compare it. - if tt.wants.errOptional && errCreate == nil { + if isInMem && tt.wants.inMemNoError && errCreate == nil { return } if diff := cmp.Diff(users, tt.wants.users, userCmpOptions...); diff != "" { @@ -279,10 +275,7 @@ func CreateUser( } // FindUserByID testing -func FindUserByID( - init func(UserFields, *testing.T) (influxdb.UserService, string, func()), - t *testing.T, -) { +func FindUserByID(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), isInMem bool, t *testing.T) { type args struct { id platform.ID } @@ -360,7 +353,7 @@ func FindUserByID( ctx := context.Background() user, err := s.FindUserByID(ctx, tt.args.id) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, isInMem, t) if diff := cmp.Diff(user, tt.wants.user, userCmpOptions...); diff != "" { t.Errorf("user is different -got/+want\ndiff %s", diff) @@ -370,10 +363,7 @@ func FindUserByID( } // FindUsers testing -func FindUsers( - init func(UserFields, *testing.T) (influxdb.UserService, string, func()), - t *testing.T, -) { +func FindUsers(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), isInMem bool, t *testing.T) { type args struct { ID platform.ID name string @@ -668,7 +658,7 @@ func FindUsers( } users, _, err := s.FindUsers(ctx, filter, tt.args.findOptions) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, isInMem, t) if diff := cmp.Diff(users, tt.wants.users, userCmpOptions...); diff != "" { t.Errorf("users are different -got/+want\ndiff %s", diff) @@ -678,10 +668,7 @@ func FindUsers( } // DeleteUser testing -func DeleteUser( - init func(UserFields, *testing.T) (influxdb.UserService, string, func()), - t *testing.T, -) { +func DeleteUser(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), isInMem bool, t *testing.T) { type args struct { ID platform.ID } @@ -772,7 +759,7 @@ func DeleteUser( defer done() ctx := context.Background() err := s.DeleteUser(ctx, tt.args.ID) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, isInMem, t) filter := influxdb.UserFilter{} users, _, err := s.FindUsers(ctx, filter) @@ -787,10 +774,7 @@ func DeleteUser( } // FindUser testing -func FindUser( - init func(UserFields, *testing.T) (influxdb.UserService, string, func()), - t *testing.T, -) { +func FindUser(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), isInMem bool, t *testing.T) { type args struct { filter influxdb.UserFilter } @@ -983,7 +967,7 @@ func FindUser( defer done() ctx := context.Background() user, err := s.FindUser(ctx, tt.args.filter) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, isInMem, t) if diff := cmp.Diff(user, tt.wants.user, userCmpOptions...); diff != "" { t.Errorf("users are different -got/+want\ndiff %s", diff) @@ -993,10 +977,7 @@ func FindUser( } // UpdateUser testing -func UpdateUser( - init func(UserFields, *testing.T) (influxdb.UserService, string, func()), - t *testing.T, -) { +func UpdateUser(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), isInMem bool, t *testing.T) { type args struct { name string id platform.ID @@ -1146,7 +1127,7 @@ func UpdateUser( } user, err := s.UpdateUser(ctx, tt.args.id, upd) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, isInMem, t) if diff := cmp.Diff(user, tt.wants.user, userCmpOptions...); diff != "" { t.Errorf("user is different -got/+want\ndiff %s", diff) @@ -1155,10 +1136,7 @@ func UpdateUser( } } -func UpdateUser_IndexHygiene( - init func(UserFields, *testing.T) (influxdb.UserService, string, func()), - t *testing.T, -) { +func UpdateUser_IndexHygiene(init func(UserFields, *testing.T) (influxdb.UserService, string, func()), isInMem bool, t *testing.T) { oldUserName := "user1" users := UserFields{ @@ -1202,5 +1180,5 @@ func UpdateUser_IndexHygiene( Code: errors.ENotFound, Op: influxdb.OpFindUser, Msg: "user not found", - }, false) + }) } diff --git a/testing/util.go b/testing/util.go index 3041bc688ec..29f3a813ab1 100644 --- a/testing/util.go +++ b/testing/util.go @@ -46,13 +46,17 @@ func NewTestInmemStore(t *testing.T) kv.SchemaStore { return s } -func diffPlatformErrors(name string, actual, expected error, errOptional bool, t *testing.T) { +func diffPlatformErrors(name string, actual, expected error, inMemNoError, isInMem bool, t *testing.T) { t.Helper() - ErrorsEqual(t, actual, expected, errOptional) + if inMemNoError && isInMem { + ErrorsEqual(t, actual, nil) + } else { + ErrorsEqual(t, actual, expected) + } } // ErrorsEqual checks to see if the provided errors are equivalent. -func ErrorsEqual(t *testing.T, actual, expected error, errOptional bool) { +func ErrorsEqual(t *testing.T, actual, expected error) { t.Helper() if expected == nil && actual == nil { return @@ -62,11 +66,7 @@ func ErrorsEqual(t *testing.T, actual, expected error, errOptional bool) { t.Errorf("unexpected error %s", actual.Error()) } - if errOptional && actual == nil { - return - } - - if expected != nil && !errOptional && actual == nil { + if expected != nil && actual == nil { t.Errorf("expected error %s but received nil", expected.Error()) } diff --git a/testing/variable.go b/testing/variable.go index 3ba98479597..09afaaaa44d 100644 --- a/testing/variable.go +++ b/testing/variable.go @@ -842,7 +842,7 @@ func FindVariables(init func(VariableFields, *testing.T) (influxdb.VariableServi } variables, err := s.FindVariables(ctx, filter, tt.args.findOpts) - diffPlatformErrors(tt.name, err, tt.wants.err, false, t) + diffPlatformErrors(tt.name, err, tt.wants.err, false, false, t) if diff := cmp.Diff(variables, tt.wants.variables, variableCmpOptions...); diff != "" { t.Errorf("variables are different -got/+want\ndiff %s", diff)