@@ -12,6 +12,7 @@ import 'package:test/test.dart';
1212
1313import '../src/fake_config.dart' ;
1414import '../src/service/fake_firestore_service.dart' ;
15+ import '../src/utilities/entity_generators.dart' ;
1516import '../src/utilities/mocks.mocks.dart' ;
1617import '../src/utilities/webhook_generators.dart' ;
1718
@@ -90,15 +91,23 @@ void main() {
9091 );
9192 });
9293
93- test ('does not add commit to db if it exists in Firestore' , () async {
94+ // Regression test for https://github.com/flutter/flutter/issues/168684.
95+ test ('does not update commit in db if SHA exists in Firestore' , () async {
96+ firestore.putDocument (
97+ generateFirestoreCommit (1 , branch: branch, sha: sha),
98+ );
99+
94100 when (
95101 githubService.getReference (
96102 RepositorySlug (owner, repository),
97- 'heads/$branch ' ,
103+ 'heads/$branch -different ' ,
98104 ),
99105 ).thenAnswer ((Invocation invocation) {
100106 return Future <GitReference >.value (
101- GitReference (ref: 'refs/$branch ' , object: GitObject ('' , sha, '' )),
107+ GitReference (
108+ ref: 'refs/$branch -different' ,
109+ object: GitObject ('' , sha, '' ),
110+ ),
102111 );
103112 });
104113
@@ -119,12 +128,15 @@ void main() {
119128 });
120129
121130 final createEvent = generateCreateBranchEvent (
122- branch,
131+ '$ branch -different' ,
123132 '$owner /$repository ' ,
124133 );
125134 await commitService.handleCreateGithubRequest (createEvent);
126135
127- expect (firestore, existsInStorage (fs.Commit .metadata, hasLength (1 )));
136+ expect (
137+ firestore,
138+ existsInStorage (fs.Commit .metadata, [isCommit.hasBranch (branch)]),
139+ );
128140 });
129141 });
130142
@@ -155,9 +167,14 @@ void main() {
155167 );
156168 });
157169
158- test ('does not add commit to db if it exists in Firestore' , () async {
170+ // Regression test for https://github.com/flutter/flutter/issues/168684.
171+ test ('does not update commit in db if SHA exists in Firestore' , () async {
172+ firestore.putDocument (
173+ generateFirestoreCommit (1 , branch: branch, sha: sha),
174+ );
175+
159176 final pushEvent = generatePushEvent (
160- branch,
177+ '$ branch -different' ,
161178 owner,
162179 repository,
163180 message: message,
@@ -167,7 +184,10 @@ void main() {
167184 );
168185 await commitService.handlePushGithubRequest (pushEvent);
169186
170- expect (firestore, existsInStorage (fs.Commit .metadata, hasLength (1 )));
187+ expect (
188+ firestore,
189+ existsInStorage (fs.Commit .metadata, [isCommit.hasBranch (branch)]),
190+ );
171191 });
172192 });
173193}
0 commit comments