@@ -143,6 +143,129 @@ public async Task ConfigWithExistingInternalFeed_DoesNotDuplicate()
143143 // Should have 4 total sources (3 original + 1 added transport)
144144 modifiedConfig . GetPackageSourceCount ( ) . Should ( ) . Be ( 4 , "should not duplicate existing sources" ) ;
145145 }
146+
147+ [ Fact ]
148+ public async Task ConfigWithDotNetEng_AddsDotNetEngInternal ( )
149+ {
150+ // Arrange
151+ var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
152+ <configuration>
153+ <packageSources>
154+ <add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
155+ <add key=""dotnet-eng"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"" />
156+ </packageSources>
157+ </configuration>" ;
158+ var configPath = Path . Combine ( _testOutputDirectory , "nuget.config" ) ;
159+ await Task . Run ( ( ) => File . WriteAllText ( configPath , originalConfig ) ) ;
160+
161+ // Act
162+ var result = await _scriptRunner . RunScript ( configPath ) ;
163+
164+ // Assert
165+ result . exitCode . Should ( ) . Be ( 0 , "Script should succeed, but got error: {0}" , result . error ) ;
166+ var modifiedConfig = await Task . Run ( ( ) => File . ReadAllText ( configPath ) ) ;
167+
168+ modifiedConfig . ShouldContainPackageSource ( "dotnet-eng-internal" ,
169+ "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/v3/index.json" ,
170+ "should add dotnet-eng-internal feed" ) ;
171+
172+ // Should have 3 total sources (2 original + 1 added internal)
173+ modifiedConfig . GetPackageSourceCount ( ) . Should ( ) . Be ( 3 , "should add internal feed" ) ;
174+ }
175+
176+ [ Fact ]
177+ public async Task ConfigWithDotNetTools_AddsDotNetToolsInternal ( )
178+ {
179+ // Arrange
180+ var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
181+ <configuration>
182+ <packageSources>
183+ <add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
184+ <add key=""dotnet-tools"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"" />
185+ </packageSources>
186+ </configuration>" ;
187+ var configPath = Path . Combine ( _testOutputDirectory , "nuget.config" ) ;
188+ await Task . Run ( ( ) => File . WriteAllText ( configPath , originalConfig ) ) ;
189+
190+ // Act
191+ var result = await _scriptRunner . RunScript ( configPath ) ;
192+
193+ // Assert
194+ result . exitCode . Should ( ) . Be ( 0 , "Script should succeed, but got error: {0}" , result . error ) ;
195+ var modifiedConfig = await Task . Run ( ( ) => File . ReadAllText ( configPath ) ) ;
196+
197+ modifiedConfig . ShouldContainPackageSource ( "dotnet-tools-internal" ,
198+ "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/v3/index.json" ,
199+ "should add dotnet-tools-internal feed" ) ;
200+
201+ // Should have 3 total sources (2 original + 1 added internal)
202+ modifiedConfig . GetPackageSourceCount ( ) . Should ( ) . Be ( 3 , "should add internal feed" ) ;
203+ }
204+
205+ [ Fact ]
206+ public async Task ConfigWithDotNetEngAndTools_AddsBothInternalFeeds ( )
207+ {
208+ // Arrange
209+ var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
210+ <configuration>
211+ <packageSources>
212+ <add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
213+ <add key=""dotnet-eng"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"" />
214+ <add key=""dotnet-tools"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"" />
215+ </packageSources>
216+ </configuration>" ;
217+ var configPath = Path . Combine ( _testOutputDirectory , "nuget.config" ) ;
218+ await Task . Run ( ( ) => File . WriteAllText ( configPath , originalConfig ) ) ;
219+
220+ // Act
221+ var result = await _scriptRunner . RunScript ( configPath ) ;
222+
223+ // Assert
224+ result . exitCode . Should ( ) . Be ( 0 , "Script should succeed, but got error: {0}" , result . error ) ;
225+ var modifiedConfig = await Task . Run ( ( ) => File . ReadAllText ( configPath ) ) ;
226+
227+ modifiedConfig . ShouldContainPackageSource ( "dotnet-eng-internal" ,
228+ "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-eng-internal/nuget/v3/index.json" ,
229+ "should add dotnet-eng-internal feed" ) ;
230+
231+ modifiedConfig . ShouldContainPackageSource ( "dotnet-tools-internal" ,
232+ "https://pkgs.dev.azure.com/dnceng/internal/_packaging/dotnet-tools-internal/nuget/v3/index.json" ,
233+ "should add dotnet-tools-internal feed" ) ;
234+
235+ // Should have 5 total sources (3 original + 2 added internal)
236+ modifiedConfig . GetPackageSourceCount ( ) . Should ( ) . Be ( 5 , "should add both internal feeds" ) ;
237+ }
238+
239+ [ Fact ]
240+ public async Task ConfigWithoutDotNetEngOrTools_DoesNotAddInternalFeeds ( )
241+ {
242+ // Arrange
243+ var originalConfig = @"<?xml version=""1.0"" encoding=""utf-8""?>
244+ <configuration>
245+ <packageSources>
246+ <add key=""dotnet-public"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json"" />
247+ <add key=""dotnet9"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json"" />
248+ </packageSources>
249+ </configuration>" ;
250+ var configPath = Path . Combine ( _testOutputDirectory , "nuget.config" ) ;
251+ await Task . Run ( ( ) => File . WriteAllText ( configPath , originalConfig ) ) ;
252+
253+ // Act
254+ var result = await _scriptRunner . RunScript ( configPath ) ;
255+
256+ // Assert
257+ result . exitCode . Should ( ) . Be ( 0 , "Script should succeed, but got error: {0}" , result . error ) ;
258+ var modifiedConfig = await Task . Run ( ( ) => File . ReadAllText ( configPath ) ) ;
259+
260+ modifiedConfig . ShouldNotContainPackageSource ( "dotnet-eng-internal" ,
261+ "should not add dotnet-eng-internal when dotnet-eng is not present" ) ;
262+ modifiedConfig . ShouldNotContainPackageSource ( "dotnet-tools-internal" ,
263+ "should not add dotnet-tools-internal when dotnet-tools is not present" ) ;
264+
265+ // Should add dotnet9 internal feeds
266+ modifiedConfig . ShouldContainPackageSource ( "dotnet9-internal" ) ;
267+ modifiedConfig . ShouldContainPackageSource ( "dotnet9-internal-transport" ) ;
268+ }
146269 }
147270}
148271
0 commit comments