From 5b42a8adc47779feed0bb050bacec8b39bcedf07 Mon Sep 17 00:00:00 2001 From: 64J0 Date: Fri, 12 Apr 2024 09:47:46 -0300 Subject: [PATCH] test: add new DeleteRelationshipsAsync test scenario to check whether the subject id is working --- SpiceDb.Tests/SpiceDbClientTests.cs | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/SpiceDb.Tests/SpiceDbClientTests.cs b/SpiceDb.Tests/SpiceDbClientTests.cs index 3f12236..4d63df9 100644 --- a/SpiceDb.Tests/SpiceDbClientTests.cs +++ b/SpiceDb.Tests/SpiceDbClientTests.cs @@ -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 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 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()