@@ -189,6 +189,37 @@ func TestCouplesConsumeFinalize(t *testing.T) {
189189 assert .Equal (t , cr .FilesMatrix [2 ][2 ], int64 (3 ))
190190}
191191
192+ func TestCouplesConsumeFinalizeMerge (t * testing.T ) {
193+ c := fixtureCouples ()
194+ deps := map [string ]interface {}{}
195+ deps [identity .DependencyAuthor ] = 0
196+ deps [core .DependencyCommit ], _ = test .Repository .CommitObject (gitplumbing .NewHash (
197+ "a3ee37f91f0d705ec9c41ae88426f0ae44b2fbc3" ))
198+ deps [core .DependencyIsMerge ] = true
199+ deps [plumbing .DependencyTreeChanges ] = generateChanges ("+LICENSE2" , "+file2.go" )
200+ c .Consume (deps )
201+ deps [plumbing .DependencyTreeChanges ] = generateChanges ("+file2.go" , "-LICENSE2" , ">file2.go>file_test.go" )
202+ c .Consume (deps )
203+ assert .Equal (t , len (c .people [0 ]), 3 )
204+ assert .Equal (t , c .people [0 ]["LICENSE2" ], 1 )
205+ assert .Equal (t , c .people [0 ]["file2.go" ], 1 )
206+ assert .Equal (t , c .people [0 ]["file_test.go" ], 1 )
207+ for i := 1 ; i < 3 ; i ++ {
208+ assert .Equal (t , len (c .people [i ]), 0 )
209+ }
210+ assert .Equal (t , c .files ["LICENSE2" ], map [string ]int {
211+ "LICENSE2" : 1 ,
212+ "file2.go" : 1 ,
213+ })
214+ assert .Equal (t , c .files ["file2.go" ], map [string ]int {
215+ "file2.go" : 1 ,
216+ "LICENSE2" : 1 ,
217+ })
218+ assert .Equal (t , c .files ["file_test.go" ], map [string ]int {
219+ "file_test.go" : 1 ,
220+ })
221+ }
222+
192223func TestCouplesConsumeFinalizeAuthorMissing (t * testing.T ) {
193224 c := fixtureCouples ()
194225 deps := map [string ]interface {}{}
@@ -314,7 +345,7 @@ func TestCouplesSerialize(t *testing.T) {
314345 reversedPeopleDict : []string {"p1" , "p2" , "p3" },
315346 }
316347 buffer := & bytes.Buffer {}
317- c .Serialize (result , false , buffer )
348+ assert . Nil ( t , c .Serialize (result , false , buffer ) )
318349 assert .Equal (t , buffer .String (), ` files_coocc:
319350 index:
320351 - "five"
@@ -346,9 +377,9 @@ func TestCouplesSerialize(t *testing.T) {
346377 - "three"
347378` )
348379 buffer = & bytes.Buffer {}
349- c .Serialize (result , true , buffer )
380+ assert . Nil ( t , c .Serialize (result , true , buffer ) )
350381 msg := pb.CouplesAnalysisResults {}
351- proto .Unmarshal (buffer .Bytes (), & msg )
382+ assert . Nil ( t , proto .Unmarshal (buffer .Bytes (), & msg ) )
352383 assert .Len (t , msg .PeopleFiles , 3 )
353384 tmp1 := [... ]int32 {0 , 1 , 2 }
354385 assert .Equal (t , msg .PeopleFiles [0 ].Files , tmp1 [:])
0 commit comments