From 3f2906f76688cb7d4bc8b88cc808e8d4be6a9021 Mon Sep 17 00:00:00 2001 From: UlyanaAndrukhiv Date: Thu, 12 Dec 2024 12:52:11 +0200 Subject: [PATCH] Updated unit tests to more readable --- .../data_providers/account_statuses_provider_test.go | 9 ++++----- .../websockets/data_providers/events_provider_test.go | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/engine/access/rest/websockets/data_providers/account_statuses_provider_test.go b/engine/access/rest/websockets/data_providers/account_statuses_provider_test.go index b6b19872d12..99aa6778744 100644 --- a/engine/access/rest/websockets/data_providers/account_statuses_provider_test.go +++ b/engine/access/rest/websockets/data_providers/account_statuses_provider_test.go @@ -74,7 +74,7 @@ func (s *AccountStatusesProviderSuite) TestAccountStatusesDataProvider_HappyPath s.T(), AccountStatusesTopic, s.factory, - s.subscribeAccountStatusesDataProviderTestCases(events, backendResponses), + s.subscribeAccountStatusesDataProviderTestCases(backendResponses), func(dataChan chan interface{}) { for i := 0; i < len(backendResponses); i++ { dataChan <- backendResponses[i] @@ -85,10 +85,9 @@ func (s *AccountStatusesProviderSuite) TestAccountStatusesDataProvider_HappyPath } func (s *AccountStatusesProviderSuite) subscribeAccountStatusesDataProviderTestCases( - events []flow.Event, backendResponses []*backend.AccountStatusesResponse, ) []testType { - expectedResponses := s.expectedAccountStatusesResponses(events, backendResponses) + expectedResponses := s.expectedAccountStatusesResponses(backendResponses) return []testType{ { @@ -282,8 +281,8 @@ func (s *AccountStatusesProviderSuite) backendAccountStatusesResponses(events [] } // expectedAccountStatusesResponses creates the expected responses for the provided events and backend responses. -func (s *AccountStatusesProviderSuite) expectedAccountStatusesResponses(events []flow.Event, backendResponses []*backend.AccountStatusesResponse) []interface{} { - expectedResponses := make([]interface{}, len(events)) +func (s *AccountStatusesProviderSuite) expectedAccountStatusesResponses(backendResponses []*backend.AccountStatusesResponse) []interface{} { + expectedResponses := make([]interface{}, len(backendResponses)) for i, resp := range backendResponses { var expectedResponse models.AccountStatusesResponse diff --git a/engine/access/rest/websockets/data_providers/events_provider_test.go b/engine/access/rest/websockets/data_providers/events_provider_test.go index 575e7695d0e..c0d914f7cdb 100644 --- a/engine/access/rest/websockets/data_providers/events_provider_test.go +++ b/engine/access/rest/websockets/data_providers/events_provider_test.go @@ -75,7 +75,7 @@ func (s *EventsProviderSuite) TestEventsDataProvider_HappyPath() { s.T(), EventsTopic, s.factory, - s.subscribeEventsDataProviderTestCases(events, backendResponses), + s.subscribeEventsDataProviderTestCases(backendResponses), func(dataChan chan interface{}) { for i := 0; i < len(backendResponses); i++ { dataChan <- backendResponses[i] @@ -86,8 +86,8 @@ func (s *EventsProviderSuite) TestEventsDataProvider_HappyPath() { } // subscribeEventsDataProviderTestCases generates test cases for events data providers. -func (s *EventsProviderSuite) subscribeEventsDataProviderTestCases(events []flow.Event, backendResponses []*backend.EventsResponse) []testType { - expectedResponses := s.expectedEventsResponses(events, backendResponses) +func (s *EventsProviderSuite) subscribeEventsDataProviderTestCases(backendResponses []*backend.EventsResponse) []testType { + expectedResponses := s.expectedEventsResponses(backendResponses) return []testType{ { @@ -309,10 +309,9 @@ func (s *EventsProviderSuite) backendEventsResponses(events []flow.Event) []*bac // expectedEventsResponses creates the expected responses for the provided events and backend responses. func (s *EventsProviderSuite) expectedEventsResponses( - events []flow.Event, backendResponses []*backend.EventsResponse, ) []interface{} { - expectedResponses := make([]interface{}, len(events)) + expectedResponses := make([]interface{}, len(backendResponses)) for i, resp := range backendResponses { var expectedResponse models.EventResponse