Skip to content

Commit

Permalink
Merge pull request #16 from 64J0/64J0-patch-1
Browse files Browse the repository at this point in the history
Add new `DeleteRelationshipsAsync` to assert that the subject Id is being used correctly
  • Loading branch information
tanczosm authored Apr 12, 2024
2 parents cac7468 + 5b42a8a commit 08520ce
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions SpiceDb.Tests/SpiceDbClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,43 @@ await _client.DeleteRelationshipsAsync(new RelationshipFilter
ClassicAssert.IsTrue(relationships.Count == 4 && relationships2.Count == 0);
}

[Test]
public async Task DeleteRelationshipsAsyncWithSubjectIdTest()
{
_client!.AddRelationship("group:delete#manager@user:test1");
_client!.AddRelationship("group:delete#manager@user:test2");
_client!.AddRelationship("group:delete#manager@user:test3");
_client!.AddRelationship("group:delete#manager@user:test4");

List<string> relationships = new();

await foreach (var response in _client!.ReadRelationshipsAsync(new RelationshipFilter { Type = "group", OptionalId = "delete" }, new RelationshipFilter { Type = "user" }, excludePrefix: true))
{
relationships.Add(response.Relationship.ToString()!);
}

await _client.DeleteRelationshipsAsync(new RelationshipFilter
{
Type = "group",
OptionalId = "delete",
OptionalRelation = "manager"
},
new RelationshipFilter
{
Type = "user",
OptionalId = "test1"
});

List<string> relationships2 = new();

await foreach (var response in _client!.ReadRelationshipsAsync(new RelationshipFilter { Type = "group", OptionalId = "delete" }, new RelationshipFilter { Type = "user" }, excludePrefix: true))
{
relationships2.Add(response.Relationship.ToString()!);
}

ClassicAssert.IsTrue(relationships.Count == 4 && relationships2.Count == 3);
}


[Test]
public void CheckPermissionAsyncTest()
Expand Down

0 comments on commit 08520ce

Please sign in to comment.