From 297fecb697f8d42a8d23196cb8f07b926e8b8d64 Mon Sep 17 00:00:00 2001 From: utsav14nov Date: Mon, 7 Oct 2024 14:24:41 +0530 Subject: [PATCH] fix: test cases --- plugins/providers/shield/client_new_test.go | 6 +++--- plugins/providers/shield/client_test.go | 13 ++++++------- plugins/providers/shield/provider_test.go | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/providers/shield/client_new_test.go b/plugins/providers/shield/client_new_test.go index ec6e5750..e8d8b7ed 100644 --- a/plugins/providers/shield/client_new_test.go +++ b/plugins/providers/shield/client_new_test.go @@ -117,7 +117,7 @@ func (s *ShieldNewClientTestSuite) getTestRequest(method, path string, body inte } func (s *ShieldNewClientTestSuite) TestShieldNewGetGroups() { - s.Run("should get teams and nil error on success", func() { + s.Run("should get groups and nil error on success", func() { s.setup() testRequest, err := s.getTestRequest(http.MethodGet, "/admin/v1beta1/groups", nil, "") @@ -357,7 +357,7 @@ func (s *ShieldNewClientTestSuite) TestShieldNewGetOrganizations() { } func (s *ShieldNewClientTestSuite) TestShieldNewGrantGroupAccess() { - s.Run("should grant access to team and nil error on success", func() { + s.Run("should grant access to group and nil error on success", func() { s.setup() testUserId := "test_user_id" @@ -459,7 +459,7 @@ func (s *ShieldNewClientTestSuite) TestShieldNewGrantOrganizationAccess() { } func (s *ShieldNewClientTestSuite) TestShieldNewRevokeGroupAccess() { - s.Run("should revoke access to team and nil error on success", func() { + s.Run("should revoke access to group and nil error on success", func() { s.setup() testUserId := "test_user_id" diff --git a/plugins/providers/shield/client_test.go b/plugins/providers/shield/client_test.go index 30336e72..21b4e60a 100644 --- a/plugins/providers/shield/client_test.go +++ b/plugins/providers/shield/client_test.go @@ -117,7 +117,7 @@ func (s *ClientTestSuite) getTestRequest(method, path string, body interface{}, } func (s *ClientTestSuite) TestGetGroups() { - s.Run("should get teams and nil error on success", func() { + s.Run("should get groups and nil error on success", func() { s.setup() testRequest, err := s.getTestRequest(http.MethodGet, "/admin/v1beta1/groups", nil, "") @@ -355,8 +355,8 @@ func (s *ClientTestSuite) TestGetOrganizations() { }) } -func (s *ClientTestSuite) TestGrantGroupAccess() { - s.Run("should grant access to team and nil error on success", func() { +func (s *ClientTestSuite) TestGrantShieldGroupAccess() { + s.Run("should grant access to group and nil error on success", func() { s.setup() testUserId := "test_user_id" @@ -364,8 +364,7 @@ func (s *ClientTestSuite) TestGrantGroupAccess() { body := make(map[string][]string) body["userIds"] = append(body["userIds"], testUserId) - var teamObj *shield.Group - teamObj = new(shield.Group) + teamObj := new(shield.Group) teamObj.ID = "test_team_id" role := "users" @@ -471,8 +470,8 @@ func (s *ClientTestSuite) TestGrantOrganizationAccess() { }) } -func (s *ClientTestSuite) TestRevokeGroupAccess() { - s.Run("should revoke access to team and nil error on success", func() { +func (s *ClientTestSuite) TestRevokeShieldGroupAccess() { + s.Run("should revoke access to group and nil error on success", func() { s.setup() testUserId := "test_user_id" diff --git a/plugins/providers/shield/provider_test.go b/plugins/providers/shield/provider_test.go index 11aca726..2a2b3c41 100644 --- a/plugins/providers/shield/provider_test.go +++ b/plugins/providers/shield/provider_test.go @@ -207,7 +207,7 @@ func TestGetResources(t *testing.T) { }, } expectedError := errors.New("client error") - client.On("GetTeams", mock.Anything).Return(nil, expectedError).Once() + client.On("GetGroups", mock.Anything).Return(nil, expectedError).Once() actualResources, actualError := p.GetResources(context.TODO(), pc) @@ -306,7 +306,7 @@ func TestGetResources(t *testing.T) { Admins: []string{"testTeamAdmin@gmail.com"}, }, } - client.On("GetTeams", mock.Anything).Return(expectedTeams, nil).Once() + client.On("GetGroups", mock.Anything).Return(expectedTeams, nil).Once() expectedProjects := []*shield.Project{ {