From 696ea58f04b69cafe24c85c2d073b6da40c703e1 Mon Sep 17 00:00:00 2001 From: rodneyosodo Date: Fri, 9 Jun 2023 14:22:50 +0300 Subject: [PATCH] Fix Linter Signed-off-by: rodneyosodo --- consumers/notifiers/api/endpoint_test.go | 2 +- consumers/notifiers/service_test.go | 2 +- pkg/sdk/go/policies_test.go | 18 ++++++++++-------- pkg/sdk/go/things_test.go | 1 - 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/consumers/notifiers/api/endpoint_test.go b/consumers/notifiers/api/endpoint_test.go index 2773f65fa6f..51240d2c5af 100644 --- a/consumers/notifiers/api/endpoint_test.go +++ b/consumers/notifiers/api/endpoint_test.go @@ -412,7 +412,7 @@ func TestRemove(t *testing.T) { desc: "remove not existing", id: "not existing", auth: token, - status: http.StatusNoContent, + status: http.StatusNotFound, }, { desc: "remove empty id", diff --git a/consumers/notifiers/service_test.go b/consumers/notifiers/service_test.go index fff44d648d8..726ae951da7 100644 --- a/consumers/notifiers/service_test.go +++ b/consumers/notifiers/service_test.go @@ -257,7 +257,7 @@ func TestRemoveSubscription(t *testing.T) { desc: "test not existing", token: exampleUser1, id: "not_exist", - err: nil, + err: errors.ErrNotFound, }, { desc: "test with empty token", diff --git a/pkg/sdk/go/policies_test.go b/pkg/sdk/go/policies_test.go index 628bbe56cd3..e6f12bbe983 100644 --- a/pkg/sdk/go/policies_test.go +++ b/pkg/sdk/go/policies_test.go @@ -28,6 +28,8 @@ import ( "github.com/stretchr/testify/mock" ) +const addExistingPolicyDesc = "add existing policy" + var ( utadminPolicy = umocks.SubjectSet{Subject: "things", Relation: []string{"g_add"}} ) @@ -75,7 +77,7 @@ func TestCreatePolicy(t *testing.T) { err: nil, }, { - desc: "add existing policy", + desc: addExistingPolicyDesc, policy: sdk.Policy{ Subject: subject, Object: object, @@ -163,7 +165,7 @@ func TestCreatePolicy(t *testing.T) { assert.True(t, ok, fmt.Sprintf("Retrieve was not called on %s", tc.desc)) ok = repoCall2.Parent.AssertCalled(t, "Save", mock.Anything, mock.Anything) assert.True(t, ok, fmt.Sprintf("Save was not called on %s", tc.desc)) - if tc.desc == "add existing policy" { + if tc.desc == addExistingPolicyDesc { ok = repoCall1.Parent.AssertCalled(t, "Update", mock.Anything, mock.Anything) assert.True(t, ok, fmt.Sprintf("Update was not called on %s", tc.desc)) } @@ -316,7 +318,7 @@ func TestAssign(t *testing.T) { err: nil, }, { - desc: "add existing policy", + desc: addExistingPolicyDesc, policy: sdk.Policy{ Subject: subject, Object: object, @@ -404,7 +406,7 @@ func TestAssign(t *testing.T) { assert.True(t, ok, fmt.Sprintf("Retrieve was not called on %s", tc.desc)) ok = repoCall2.Parent.AssertCalled(t, "Save", mock.Anything, mock.Anything) assert.True(t, ok, fmt.Sprintf("Save was not called on %s", tc.desc)) - if tc.desc == "add existing policy" { + if tc.desc == addExistingPolicyDesc { ok = repoCall1.Parent.AssertCalled(t, "Update", mock.Anything, mock.Anything) assert.True(t, ok, fmt.Sprintf("Update was not called on %s", tc.desc)) } @@ -801,7 +803,7 @@ func TestConnect(t *testing.T) { err: nil, }, { - desc: "add existing policy", + desc: addExistingPolicyDesc, policy: sdk.Policy{ Subject: subject, Object: object, @@ -889,7 +891,7 @@ func TestConnect(t *testing.T) { assert.True(t, ok, fmt.Sprintf("Retrieve was not called on %s", tc.desc)) ok = repoCall2.Parent.AssertCalled(t, "Save", mock.Anything, mock.Anything) assert.True(t, ok, fmt.Sprintf("Save was not called on %s", tc.desc)) - if tc.desc == "add existing policy" { + if tc.desc == addExistingPolicyDesc { ok = repoCall1.Parent.AssertCalled(t, "Update", mock.Anything, mock.Anything) assert.True(t, ok, fmt.Sprintf("Update was not called on %s", tc.desc)) } @@ -940,7 +942,7 @@ func TestConnectThing(t *testing.T) { err: nil, }, { - desc: "add existing policy", + desc: addExistingPolicyDesc, policy: sdk.Policy{ Subject: subject, Object: object, @@ -1027,7 +1029,7 @@ func TestConnectThing(t *testing.T) { assert.True(t, ok, fmt.Sprintf("Retrieve was not called on %s", tc.desc)) ok = repoCall2.Parent.AssertCalled(t, "Save", mock.Anything, mock.Anything) assert.True(t, ok, fmt.Sprintf("Save was not called on %s", tc.desc)) - if tc.desc == "add existing policy" { + if tc.desc == addExistingPolicyDesc { ok = repoCall1.Parent.AssertCalled(t, "Update", mock.Anything, mock.Anything) assert.True(t, ok, fmt.Sprintf("Update was not called on %s", tc.desc)) } diff --git a/pkg/sdk/go/things_test.go b/pkg/sdk/go/things_test.go index 498ab92ed31..e810e2a90fe 100644 --- a/pkg/sdk/go/things_test.go +++ b/pkg/sdk/go/things_test.go @@ -31,7 +31,6 @@ var ( adminID = generateUUID(&testing.T{}) users = map[string]string{adminToken: adminID} ID = testsutil.GenerateUUID(&testing.T{}, idProvider) - tadminPolicy = mocks.MockSubjectSet{Object: ID, Relation: clients.AdminRelationKey} uadminPolicy = cmocks.SubjectSet{Subject: ID, Relation: clients.AdminRelationKey} )