Skip to content

Commit

Permalink
Updated unit tests to more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
UlyanaAndrukhiv committed Dec 12, 2024
1 parent 5c4f672 commit 3f2906f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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{
{
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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{
{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3f2906f

Please sign in to comment.