implement integration test for relationship update and delete

This commit is contained in:
2025-04-24 16:06:20 +02:00
parent c8d68c5cc7
commit cd2116622f
10 changed files with 96 additions and 16 deletions

View File

@@ -90,8 +90,8 @@ func (srv *server) UpdateRelationship(c *gin.Context, id1, id2 int, params api.U
actx, aCancel := context.WithTimeout(c.Request.Context(), srv.dbOpTimeout)
defer aCancel()
if err := auth.CouldManagePersonUnknownAdmin(actx, session, *relationship.Id1, params.XUserID); err != nil {
if err := auth.CouldManagePersonUnknownAdmin(actx, session, *relationship.Id2, params.XUserID); err != nil {
if err := auth.CouldManagePersonUnknownAdmin(actx, session, id1, params.XUserID); err != nil {
if err := auth.CouldManagePersonUnknownAdmin(actx, session, id2, params.XUserID); err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"msg": fmt.Sprint("User does not have access to this person", err.Error())})
return

View File

@@ -1,3 +1,3 @@
MATCH (a:Person)-[r]-(b:Person)
WHERE id(a) = $id1 AND id(b) = $id2 AND type(r) != Admin
WHERE id(a) = $id1 AND id(b) = $id2 AND type(r) <> "Admin"
DELETE r;

View File

@@ -1,4 +1,4 @@
MATCH (n)-[r]->(o)
WHERE id(n) = $id1 AND id(o) = $id2
SET r += $relationship
RETURN r as relationship
RETURN collect(r) as relationship