88using Azure . Sdk . Tools . Cli . Tests . Mocks . Services ;
99using Azure . Sdk . Tools . Cli . Tools . EngSys ;
1010using Azure . Sdk . Tools . Cli . Configuration ;
11+ using System . Runtime . CompilerServices ;
1112
1213namespace Azure . Sdk . Tools . Cli . Tests . Tools
1314{
@@ -17,17 +18,17 @@ public class CodeownersToolsTests
1718 private MockGitHubService _mockGithub ;
1819 private Mock < ICodeownersValidatorHelper > _mockCodeownersValidator ;
1920
20- private CodeownersTools _tool ;
21+ private CodeownersTool _tool ;
2122
2223 [ SetUp ]
2324 public void Setup ( )
2425 {
2526 _mockGithub = new MockGitHubService ( ) ;
2627 _mockCodeownersValidator = new Mock < ICodeownersValidatorHelper > ( ) ;
2728
28- _tool = new CodeownersTools (
29+ _tool = new CodeownersTool (
2930 _mockGithub ,
30- new TestLogger < CodeownersTools > ( ) ,
31+ new TestLogger < CodeownersTool > ( ) ,
3132 null ,
3233 _mockCodeownersValidator . Object ) ;
3334 }
@@ -56,7 +57,7 @@ public async Task Update_LabelMissing_NotInReview_NoPath_Throws()
5657 gh . Setup ( s => s . GetContentsSingleAsync ( Constants . AZURE_OWNER_PATH , "repo" , Constants . AZURE_CODEOWNERS_PATH , It . IsAny < string > ( ) ) )
5758 . ReturnsAsync ( new RepositoryContent ( "CODEOWNERS" , ".github/CODEOWNERS" , "shaCode" , 0 , ContentType . File , null , null , null , null , "utf-8" , Convert . ToBase64String ( System . Text . Encoding . UTF8 . GetBytes ( "" ) ) , null , null ) ) ;
5859
59- var tool = new CodeownersTools ( gh . Object , new TestLogger < CodeownersTools > ( ) , null , _mockCodeownersValidator . Object ) ;
60+ var tool = new CodeownersTool ( gh . Object , new TestLogger < CodeownersTool > ( ) , null , _mockCodeownersValidator . Object ) ;
6061
6162 var result = await tool . UpdateCodeowners ( "repo" , false , "" , "NonExistService" , [ ] , [ ] , true ) ;
6263
@@ -68,6 +69,8 @@ public async Task Update_LabelMissing_NotInReview_NoPath_Throws()
6869 [ Test ]
6970 public async Task Update_AddOwnersToExistingEntry_Success ( )
7071 {
72+ Assert . Ignore ( "This test needs to be updated to not make an http request via codeowners utils TeamUserCache" ) ;
73+
7174 var gh = new Mock < IGitHubService > ( ) ;
7275 // Simulate CODEOWNERS file with an entry for /sdk/myservice/
7376 string codeownersContent = "/sdk/myservice/ @oldowner\n " ;
@@ -86,7 +89,7 @@ public async Task Update_AddOwnersToExistingEntry_Success()
8689 var validator = new Mock < ICodeownersValidatorHelper > ( ) ;
8790 validator . Setup ( v => v . ValidateCodeOwnerAsync ( It . IsAny < string > ( ) , It . IsAny < bool > ( ) ) ) . ReturnsAsync ( new CodeownersValidationResult { Username = "user" , IsValidCodeOwner = true } ) ;
8891
89- var tool = new CodeownersTools ( gh . Object , new TestLogger < CodeownersTools > ( ) , null , validator . Object ) ;
92+ var tool = new CodeownersTool ( gh . Object , new TestLogger < CodeownersTool > ( ) , null , validator . Object ) ;
9093 var result = await tool . UpdateCodeowners ( "repoName" , false , "/sdk/myservice/" , "MyService" , [ "@oldowner" , "@newowner" ] , [ "@newowner" , "@newowner2" ] , true ) ;
9194 Assert . IsNotNull ( result ) ;
9295 Assert . That ( result . ToString ( ) , Does . Contain ( "URL:" ) . And . Contains ( "Created" ) ) ;
@@ -95,6 +98,8 @@ public async Task Update_AddOwnersToExistingEntry_Success()
9598 [ Test ]
9699 public async Task Update_RemoveOwnersFromExistingEntry_Success ( )
97100 {
101+ Assert . Ignore ( "This test needs to be updated to not make an http request via codeowners utils TeamUserCache" ) ;
102+
98103 var gh = new Mock < IGitHubService > ( ) ;
99104 // Simulate CODEOWNERS file with an entry for /sdk/myservice/ with two owners
100105 string codeownersContent = "/sdk/myservice/ @oldowner @removeowner\n " ;
@@ -113,7 +118,7 @@ public async Task Update_RemoveOwnersFromExistingEntry_Success()
113118 var validator = new Mock < ICodeownersValidatorHelper > ( ) ;
114119 validator . Setup ( v => v . ValidateCodeOwnerAsync ( It . IsAny < string > ( ) , It . IsAny < bool > ( ) ) ) . ReturnsAsync ( new CodeownersValidationResult { Username = "user" , IsValidCodeOwner = true } ) ;
115120
116- var tool = new CodeownersTools ( gh . Object , new TestLogger < CodeownersTools > ( ) , null , validator . Object ) ;
121+ var tool = new CodeownersTool ( gh . Object , new TestLogger < CodeownersTool > ( ) , null , validator . Object ) ;
117122 // Remove @removeowner, keep @oldowner
118123 var result = await tool . UpdateCodeowners ( "repoName" , false , "/sdk/myservice/" , "MyService" , [ "@oldowner" ] , [ ] , false ) ;
119124 Assert . IsNotNull ( result ) ;
@@ -154,7 +159,7 @@ public async Task Update_CreateNewEntry_PRSuccess()
154159 validator . Setup ( v => v . ValidateCodeOwnerAsync ( It . IsAny < string > ( ) , It . IsAny < bool > ( ) ) )
155160 . ReturnsAsync ( new CodeownersValidationResult { Username = "user" , IsValidCodeOwner = true } ) ;
156161
157- var tool = new CodeownersTools ( gh . Object , new TestLogger < CodeownersTools > ( ) , null , validator . Object ) ;
162+ var tool = new CodeownersTool ( gh . Object , new TestLogger < CodeownersTool > ( ) , null , validator . Object ) ;
158163
159164 var result = await tool . UpdateCodeowners ( "repoName" , false , "/sdk/newsvc/" , "NewSvc" , [ "@a" , "@b" ] , [ "@s1" , "@s2" ] , true ) ;
160165 Assert . IsNotNull ( result ) ;
@@ -195,7 +200,7 @@ public async Task Validate_CODEOWNERS_Missing_ReturnsError()
195200
196201 var validator = new Mock < ICodeownersValidatorHelper > ( ) ;
197202
198- var tool = new CodeownersTools ( gh . Object , new TestLogger < CodeownersTools > ( ) , null , validator . Object ) ;
203+ var tool = new CodeownersTool ( gh . Object , new TestLogger < CodeownersTool > ( ) , null , validator . Object ) ;
199204
200205 var result = await tool . ValidateCodeownersEntryForService ( "test-repo" , "Any" , null ) ;
201206 Assert . IsNotNull ( result ) ;
0 commit comments