Skip to content

Commit

Permalink
[PROBLEM-1079] fixing inner loop in actions_assignees (#158)
Browse files Browse the repository at this point in the history
* [PROBLEM-1079] fixing inner loop in actions_assignees

* Adding new unit test for action assignees and pr feedback
  • Loading branch information
hkf57 authored Sep 2, 2021
1 parent 9448958 commit 8ae56b0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions internal/app/feed/feed_action_assignee_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package feed_test

import (
"context"
"testing"
"time"

"github.com/SafetyCulture/iauditor-exporter/internal/app/feed"
"github.com/stretchr/testify/assert"

"github.com/SafetyCulture/iauditor-exporter/internal/app/api"
)

func TestActionAssigneeFeedExport_should_export_rows_to_sql_db(t *testing.T) {
exporter, err := getInmemorySQLExporter("")
assert.Nil(t, err)

apiClient := api.GetTestClient()
initMockFeedsSet1(apiClient.HTTPClient())

actionAssigneeFeed := feed.ActionAssigneeFeed{
ModifiedAfter: time.Now(),
Incremental: true,
}

err = actionAssigneeFeed.Export(context.Background(), apiClient, exporter, "")
assert.Nil(t, err)

rows := []feed.ActionAssignee{}
resp := exporter.DB.Table("action_assignees").Scan(&rows)
assert.Nil(t, resp.Error)

assert.Equal(t, 2, len(rows))
assert.Equal(t, "[email protected]", rows[0].AssigneeID)
}
2 changes: 1 addition & 1 deletion internal/app/feed/feed_action_assignees.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (f *ActionAssigneeFeed) writeRows(ctx context.Context, exporter Exporter, r
j = len(rows)
}
var actionIDs []string
for k := i; k < (i + j); k++ {
for k := range rows[i:j] {
actionIDs = append(actionIDs, rows[k].ActionID)
}

Expand Down

0 comments on commit 8ae56b0

Please sign in to comment.