From add76df4c528604c6fefbdae24a38d24b556fd02 Mon Sep 17 00:00:00 2001
From: Valentin Iordanov <valentin.yordanov@vereign.com>
Date: Tue, 17 Oct 2023 13:44:19 +0300
Subject: [PATCH] Fix linters

---
 .../service/policy/policydata/refresher_test.go  | 16 ++++++++--------
 internal/storage/storage.go                      |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/internal/service/policy/policydata/refresher_test.go b/internal/service/policy/policydata/refresher_test.go
index b2a0f7b0..bdfd0ace 100644
--- a/internal/service/policy/policydata/refresher_test.go
+++ b/internal/service/policy/policydata/refresher_test.go
@@ -34,7 +34,7 @@ func Test_Execute(t *testing.T) {
 		// test input
 		name       string
 		statusCode int
-		policy     storage.Policy
+		policy     *storage.Policy
 		storage    policydata.Storage
 		// expected result
 		logCnt   int
@@ -42,7 +42,7 @@ func Test_Execute(t *testing.T) {
 	}{
 		{
 			name:   "invalid data configuration",
-			policy: storage.Policy{DataConfig: "<invalid data configuration>"},
+			policy: &storage.Policy{DataConfig: "<invalid data configuration>"},
 			storage: &policydatafakes.FakeStorage{
 				UpdateNextRefreshTimeStub: func(ctx context.Context, policy *storage.Policy, t time.Time) error {
 					return nil
@@ -53,7 +53,7 @@ func Test_Execute(t *testing.T) {
 		},
 		{
 			name:   "data configuration is missing required fields",
-			policy: storage.Policy{DataConfig: `{"url": "https://example.com"}`},
+			policy: &storage.Policy{DataConfig: `{"url": "https://example.com"}`},
 			storage: &policydatafakes.FakeStorage{
 				UpdateNextRefreshTimeStub: func(ctx context.Context, policy *storage.Policy, t time.Time) error {
 					return nil
@@ -64,7 +64,7 @@ func Test_Execute(t *testing.T) {
 		},
 		{
 			name:   "error making an http request",
-			policy: storage.Policy{DataConfig: `{"url": "htt//example.com", "method": "GET", "period": "1h"}`},
+			policy: &storage.Policy{DataConfig: `{"url": "htt//example.com", "method": "GET", "period": "1h"}`},
 			storage: &policydatafakes.FakeStorage{
 				UpdateNextRefreshTimeStub: func(ctx context.Context, policy *storage.Policy, t time.Time) error {
 					return nil
@@ -76,7 +76,7 @@ func Test_Execute(t *testing.T) {
 		{
 			name:       "unexpected response code",
 			statusCode: 500,
-			policy:     storage.Policy{DataConfig: `{"url": "https://example.com", "method": "GET", "period": "1h"}`},
+			policy:     &storage.Policy{DataConfig: `{"url": "https://example.com", "method": "GET", "period": "1h"}`},
 			storage: &policydatafakes.FakeStorage{
 				UpdateNextRefreshTimeStub: func(ctx context.Context, policy *storage.Policy, t time.Time) error {
 					return nil
@@ -87,7 +87,7 @@ func Test_Execute(t *testing.T) {
 		},
 		{
 			name:   "error updating data after successful refresh request",
-			policy: storage.Policy{DataConfig: `{"url": "https://example.com", "method": "GET", "period": "1h"}`},
+			policy: &storage.Policy{DataConfig: `{"url": "https://example.com", "method": "GET", "period": "1h"}`},
 			storage: &policydatafakes.FakeStorage{
 				UpdateNextRefreshTimeStub: func(ctx context.Context, policy *storage.Policy, t time.Time) error {
 					return errors.New("storage error")
@@ -98,7 +98,7 @@ func Test_Execute(t *testing.T) {
 		},
 		{
 			name:   "data refresh is successfully executed",
-			policy: storage.Policy{DataConfig: `{"url": "https://example.com", "method": "GET", "period": "1h"}`},
+			policy: &storage.Policy{DataConfig: `{"url": "https://example.com", "method": "GET", "period": "1h"}`},
 			storage: &policydatafakes.FakeStorage{
 				UpdateNextRefreshTimeStub: func(ctx context.Context, policy *storage.Policy, t time.Time) error {
 					return nil
@@ -121,7 +121,7 @@ func Test_Execute(t *testing.T) {
 				})
 			}
 			refresher := policydata.NewRefresher(test.storage, time.Duration(0), httpClient, logger)
-			refresher.Execute(context.Background(), (*storage.Policy)(&test.policy))
+			refresher.Execute(context.Background(), test.policy)
 
 			assert.Equal(t, test.logCnt, observedLogs.Len())
 			if observedLogs.Len() > 0 {
diff --git a/internal/storage/storage.go b/internal/storage/storage.go
index f30c7a67..e2941139 100644
--- a/internal/storage/storage.go
+++ b/internal/storage/storage.go
@@ -165,9 +165,9 @@ func (s *Storage) GetRefreshPolicies(ctx context.Context) ([]*Policy, error) {
 // PostponeRefresh adds a refreshPostponePeriod Duration to each policy's
 // nextDataRefreshTimeField in order to prevent concurrent data refresh
 func (s *Storage) PostponeRefresh(ctx context.Context, policies []*Policy) error {
-	var ids []*primitive.ObjectID
+	var ids []primitive.ObjectID
 	for _, p := range policies {
-		ids = append(ids, (*primitive.ObjectID)(&p.ID))
+		ids = append(ids, p.ID)
 	}
 
 	filter := bson.M{"_id": bson.M{"$in": ids}}
-- 
GitLab