Skip to content

Commit

Permalink
Fix PR due to updates
Browse files Browse the repository at this point in the history
Signed-off-by: Kyriakos Chatzidimitriou <[email protected]>
  • Loading branch information
kyrcha committed Oct 14, 2019
1 parent 179269a commit 62f3181
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
1 change: 1 addition & 0 deletions examples/cmd/testing/recordingscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func encodeAndStore(filename string, reqResp map[string]string) error {
if err != nil {
return err
}
defer encodeFile.Close()
zw := gzip.NewWriter(encodeFile)
defer zw.Close()
return gob.NewEncoder(zw).Encode(reqResp)
Expand Down
16 changes: 8 additions & 8 deletions github/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (
)

const (
orgRecFile = "../testdata/organization_src-d_2019-10-11.gob.gz"
repoRecFile = "../testdata/repository_src-d_gitbase_2019-10-11.gob.gz"
orgRecFile = "../testdata/organization_src-d_2019-10-14.gob.gz"
repoRecFile = "../testdata/repository_src-d_gitbase_2019-10-14.gob.gz"
onlineRepoTests = "../testdata/online-repository-tests.json"
onlineOrgTests = "../testdata/online-organization-tests.json"
offlineRepoTests = "../testdata/offline-repository-tests.json"
Expand Down Expand Up @@ -327,7 +327,7 @@ func (suite *DownloaderTestSuite) TestOnlineOrganizationDownloadWithDB() {
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
)), suite.db)
suite.NoError(err, "Failed to init the downloader")
downloader.SetActiveVersion(0)
downloader.SetActiveVersion(context.TODO(), 0)
suite.downloader = downloader
for _, test := range tests.OrganizationsTests {
test := test
Expand Down Expand Up @@ -425,7 +425,7 @@ func (suite *DownloaderTestSuite) TestOnlineRepositoryDownloadWithDB() {
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
)), suite.db)
suite.NoError(err, "Failed to init the downloader")
downloader.SetActiveVersion(0)
downloader.SetActiveVersion(context.TODO(), 0)
suite.downloader = downloader
for _, test := range tests.RepositoryTests {
test := test
Expand All @@ -445,7 +445,7 @@ func (suite *DownloaderTestSuite) TestOfflineOrganizationDownloadWithDB() {
// Not using the NewStdoutDownloader initialization because it overides the transport
storer := &store.DB{DB: suite.db}
downloader := getRoundTripDownloader(reqResp, storer)
downloader.SetActiveVersion(0) // Will create the views
downloader.SetActiveVersion(context.TODO(), 0) // Will create the views
suite.downloader = downloader
tests, err := loadTests(offlineOrgTests)
suite.NoError(err, "Failed to read the offline tests")
Expand All @@ -465,7 +465,7 @@ func (suite *DownloaderTestSuite) TestOfflineRepositoryDownloadWithDB() {
suite.NoError(loadReqResp(repoRecFile, reqResp), "Failed to read the recordings")
storer := &store.DB{DB: suite.db}
downloader := getRoundTripDownloader(reqResp, storer)
downloader.SetActiveVersion(0)
downloader.SetActiveVersion(context.TODO(), 0)
suite.downloader = downloader
tests, err := loadTests(offlineRepoTests)
suite.NoError(err, "Failed to read the offline tests")
Expand All @@ -487,15 +487,15 @@ func (suite *DownloaderTestSuite) BeforeTest(suiteName, testName string) {
func (suite *DownloaderTestSuite) AfterTest(suiteName, testName string) {
if testName == "TestOnlineOrganizationDownloadWithDB" || testName == "TestOfflineOrganizationDownloadWithDB" {
// I cleanup with a different version (1 vs. 0), so to clean all the data from the DB
suite.downloader.Cleanup(1)
suite.downloader.Cleanup(context.TODO(), 1)
// Check
var countOrgs int
err := suite.db.QueryRow("select count(*) from organizations").Scan(&countOrgs)
suite.NoError(err, "Failed to count the orgs")
suite.Equal(0, countOrgs)
} else if testName == "TestOnlineRepositoryDownloadWithDB" || testName == "TestOfflineRepositoryDownloadWithDB" {
// I cleanup with a different version (1 vs. 0), so to clean all the data from the DB
suite.downloader.Cleanup(1)
suite.downloader.Cleanup(context.TODO(), 1)
// Check
var countRepos int
err := suite.db.QueryRow("select count(*) from repositories").Scan(&countRepos)
Expand Down
4 changes: 2 additions & 2 deletions testdata/offline-organization-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"version": 0,
"url": "https://github.com/src-d",
"createdAt": "2015-10-14 17:13:24 +0000 UTC",
"publicRepos": 144,
"totalPrivateRepos": 40,
"publicRepos": 145,
"totalPrivateRepos": 41,
"numOfUsers": 54
}
]
Expand Down
6 changes: 3 additions & 3 deletions testdata/offline-repository-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"isArchived": false,
"hasWiki": false,
"numOfPrs": 548,
"numOfPrComments": 744,
"numOfPrComments": 746,
"numOfIssues": 398,
"numOfIssueComments": 964,
"numOfPRReviews": 1511,
"numOfIssueComments": 965,
"numOfPRReviews": 1512,
"numOfPRReviewComments": 668
}
]
Expand Down
Binary file removed testdata/organization_src-d_2019-10-11.gob.gz
Binary file not shown.
Binary file added testdata/organization_src-d_2019-10-14.gob.gz
Binary file not shown.
Binary file removed testdata/repository_src-d_gitbase_2019-10-11.gob.gz
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions testutils/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ func (s *Memory) SaveRepository(ctx context.Context, repository *graphql.Reposit
}

// SaveIssue appends an issue to the issue list in memory
func (s *Memory) SaveIssue(repositoryOwner, repositoryName string, issue *graphql.Issue, assignees []string, labels []string) error {
func (s *Memory) SaveIssue(ctx context.Context, repositoryOwner, repositoryName string, issue *graphql.Issue, assignees []string, labels []string) error {
log.Infof("issue data fetched for #%v %s\n", issue.Number, issue.Title)
s.Issues = append(s.Issues, issue)
return nil
}

// SaveIssueComment appends an issue comment to the issue comments list in memory
func (s *Memory) SaveIssueComment(repositoryOwner, repositoryName string, issueNumber int, comment *graphql.IssueComment) error {
func (s *Memory) SaveIssueComment(ctx context.Context, repositoryOwner, repositoryName string, issueNumber int, comment *graphql.IssueComment) error {
log.Infof("\tissue comment data fetched by %s at %v: %q\n", comment.Author.Login, comment.CreatedAt, trim(comment.Body))
s.IssueComments = append(s.IssueComments, comment)
return nil
}

// SavePullRequest appends an PR to the PR list in memory, also initializes the map for the review commnets for that particular PR
func (s *Memory) SavePullRequest(repositoryOwner, repositoryName string, pr *graphql.PullRequest, assignees []string, labels []string) error {
func (s *Memory) SavePullRequest(ctx context.Context, repositoryOwner, repositoryName string, pr *graphql.PullRequest, assignees []string, labels []string) error {
log.Infof("PR data fetched for #%v %s\n", pr.Number, pr.Title)
s.PRs = append(s.PRs, pr)
s.PRReviewComments[pr.Number] = make(map[int][]*graphql.PullRequestReviewComment)
Expand All @@ -97,14 +97,14 @@ func (s *Memory) SavePullRequestComment(ctx context.Context, repositoryOwner, re
}

// SavePullRequestReview appends a PR review to the PR review list in memory
func (s *Memory) SavePullRequestReview(repositoryOwner, repositoryName string, pullRequestNumber int, review *graphql.PullRequestReview) error {
func (s *Memory) SavePullRequestReview(ctx context.Context, repositoryOwner, repositoryName string, pullRequestNumber int, review *graphql.PullRequestReview) error {
log.Infof("\tPR Review data fetched by %s at %v: %q\n", review.Author.Login, review.SubmittedAt, trim(review.Body))
s.PRReviews[pullRequestNumber] = append(s.PRReviews[pullRequestNumber], review)
return nil
}

// SavePullRequestReviewComment appends a PR review comment to the PR review comments list in memory
func (s *Memory) SavePullRequestReviewComment(repositoryOwner, repositoryName string, pullRequestNumber int, pullRequestReviewID int, comment *graphql.PullRequestReviewComment) error {
func (s *Memory) SavePullRequestReviewComment(ctx context.Context, repositoryOwner, repositoryName string, pullRequestNumber int, pullRequestReviewID int, comment *graphql.PullRequestReviewComment) error {
log.Infof("\t\tPR review comment data fetched by %s at %v: %q\n", comment.Author.Login, comment.CreatedAt, trim(comment.Body))
s.PRReviewComments[pullRequestNumber][pullRequestReviewID] = append(s.PRReviewComments[pullRequestNumber][pullRequestReviewID], comment)
return nil
Expand Down

0 comments on commit 62f3181

Please sign in to comment.