@@ -90,14 +90,34 @@ defmodule CodeCorps.GitHub.SyncTest do
90
90
end
91
91
92
92
describe "sync_project_github_repo/1" do
93
- test "syncs with the project repo" do
93
+ test "syncs and resyncs with the project repo" do
94
94
owner = "baxterthehacker"
95
95
repo = "public-repo"
96
96
github_app_installation = insert ( :github_app_installation , github_account_login: owner )
97
97
github_repo = insert ( :github_repo , github_app_installation: github_app_installation , name: repo , github_account_id: 6752317 , github_account_avatar_url: "https://avatars3.githubusercontent.com/u/6752317?v=4" , github_account_type: "User" , github_id: 35129377 )
98
98
% { project: project } = project_github_repo = insert ( :project_github_repo , github_repo: github_repo )
99
99
insert ( :task_list , project: project , inbox: true )
100
100
101
+ # Sync a first time
102
+
103
+ Sync . sync_project_github_repo ( project_github_repo )
104
+
105
+ repo = Repo . one ( GithubRepo )
106
+
107
+ assert repo . syncing_pull_requests_count == 4
108
+ assert repo . syncing_issues_count == 8
109
+ assert repo . syncing_comments_count == 12
110
+
111
+ assert Repo . aggregate ( GithubComment , :count , :id ) == 12
112
+ assert Repo . aggregate ( GithubIssue , :count , :id ) == 8
113
+ assert Repo . aggregate ( GithubPullRequest , :count , :id ) == 4
114
+ assert Repo . aggregate ( GithubUser , :count , :id ) == 10
115
+ assert Repo . aggregate ( Comment , :count , :id ) == 12
116
+ assert Repo . aggregate ( Task , :count , :id ) == 8
117
+ assert Repo . aggregate ( User , :count , :id ) == 13
118
+
119
+ # Sync a second time – should run without trouble
120
+
101
121
Sync . sync_project_github_repo ( project_github_repo )
102
122
103
123
repo = Repo . one ( GithubRepo )
0 commit comments