Skip to content

Commit 8bcf2b7

Browse files
committed
add test for IsInConflict function
1 parent 48b879d commit 8bcf2b7

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

db/hybrid_logical_vector_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,3 +1413,51 @@ func TestAddVersion(t *testing.T) {
14131413
})
14141414
}
14151415
}
1416+
1417+
func TestIsInConflict(t *testing.T) {
1418+
testCases := []struct {
1419+
name string
1420+
localHLV string
1421+
incomingHLV string
1422+
expectedInConflict bool
1423+
expectedError bool
1424+
}{
1425+
{
1426+
name: "CV equal",
1427+
localHLV: "111@abc;123@def",
1428+
incomingHLV: "111@abc;123@ghi",
1429+
expectedError: true,
1430+
},
1431+
{
1432+
name: "no conflict case",
1433+
localHLV: "111@abc;123@def",
1434+
incomingHLV: "112@abc;123@ghi",
1435+
},
1436+
{
1437+
name: "local revision is newer",
1438+
localHLV: "111@abc;123@def",
1439+
incomingHLV: "100@abc;123@ghi",
1440+
expectedError: true,
1441+
},
1442+
{
1443+
name: "merge versions match",
1444+
localHLV: "130@abc,123@def,100@ghi;50@jkl",
1445+
incomingHLV: "150@mno,123@def,100@ghi;50@jkl",
1446+
},
1447+
}
1448+
for _, tc := range testCases {
1449+
t.Run(tc.name, func(t *testing.T) {
1450+
localHLV, _, err := extractHLVFromBlipString(tc.localHLV)
1451+
require.NoError(t, err)
1452+
incomingHLV, _, err := extractHLVFromBlipString(tc.incomingHLV)
1453+
1454+
inConflict, err := IsInConflict(t.Context(), localHLV, incomingHLV)
1455+
if tc.expectedError {
1456+
require.Error(t, err)
1457+
} else {
1458+
require.NoError(t, err)
1459+
}
1460+
require.Equal(t, tc.expectedInConflict, inConflict)
1461+
})
1462+
}
1463+
}

0 commit comments

Comments
 (0)