Skip to content

Commit

Permalink
test: add new DeleteRelationshipsAsync test scenario to check whether…
Browse files Browse the repository at this point in the history
… the subject id is working
  • Loading branch information
64J0 committed Apr 12, 2024
1 parent cac7468 commit 5b42a8a
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 5b42a8a

Please sign in to comment.