Skip to content

Commit 23a6075

Browse files
committed
Added test for NuGet.Config in parent folder
1 parent 1be69e3 commit 23a6075

File tree

1 file changed

+45
-16
lines changed

1 file changed

+45
-16
lines changed

src/Dotnet.Script.Tests/ScriptExecutionTests.cs

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -391,29 +391,58 @@ public void ShouldHandleLocalNuGetConfigWithRelativePath()
391391

392392
using (var packageLibraryFolder = new DisposableFolder())
393393
{
394-
ProcessHelper.RunAndCaptureOutput("dotnet", "new classlib -n NuGetConfigTestLibrary", packageLibraryFolder.Path);
395-
var projectFolder = Path.Combine(packageLibraryFolder.Path, "NuGetConfigTestLibrary");
396-
ProcessHelper.RunAndCaptureOutput("dotnet", $"pack -o {Path.Combine(packageLibraryFolder.Path, "packagePath")}", projectFolder);
397-
string nugetConfig = @"
394+
CreateTestPackage(packageLibraryFolder);
395+
396+
string pathToScriptFile = CreateTestScript(packageLibraryFolder.Path);
397+
398+
var result = ScriptTestRunner.Default.Execute(pathToScriptFile);
399+
Assert.Contains("Success", result.output);
400+
}
401+
}
402+
403+
[Fact]
404+
public void ShouldHandleLocalNuGetConfigWithRelativePathInParentFolder()
405+
{
406+
TestPathUtils.RemovePackageFromGlobalNugetCache("NuGetConfigTestLibrary");
407+
408+
using (var packageLibraryFolder = new DisposableFolder())
409+
{
410+
CreateTestPackage(packageLibraryFolder);
411+
412+
var scriptFolder = Path.Combine(packageLibraryFolder.Path, "ScriptFolder");
413+
Directory.CreateDirectory(scriptFolder);
414+
string pathToScriptFile = CreateTestScript(scriptFolder);
415+
416+
var result = ScriptTestRunner.Default.Execute(pathToScriptFile);
417+
Assert.Contains("Success", result.output);
418+
}
419+
}
420+
421+
private static string CreateTestScript(string scriptFolder)
422+
{
423+
string script = @"
424+
#r ""nuget:NuGetConfigTestLibrary, 1.0.0""
425+
WriteLine(""Success"");
426+
";
427+
string pathToScriptFile = Path.Combine(scriptFolder, "testscript.csx");
428+
File.WriteAllText(pathToScriptFile, script);
429+
return pathToScriptFile;
430+
}
431+
432+
private static void CreateTestPackage(DisposableFolder packageLibraryFolder)
433+
{
434+
ProcessHelper.RunAndCaptureOutput("dotnet", "new classlib -n NuGetConfigTestLibrary", packageLibraryFolder.Path);
435+
var projectFolder = Path.Combine(packageLibraryFolder.Path, "NuGetConfigTestLibrary");
436+
ProcessHelper.RunAndCaptureOutput("dotnet", $"pack -o {Path.Combine(packageLibraryFolder.Path, "packagePath")}", projectFolder);
437+
string nugetConfig = @"
398438
<configuration>
399439
<packageSources>
400440
<clear/>
401441
<add key=""localSource"" value=""packagePath""/>
402442
</packageSources>
403443
></configuration>
404444
";
405-
File.WriteAllText(Path.Combine(packageLibraryFolder.Path, "NuGet.Config"), nugetConfig);
406-
407-
string script = @"
408-
#r ""nuget:NuGetConfigTestLibrary, 1.0.0""
409-
WriteLine(""Success"");
410-
";
411-
string pathToScriptFile = Path.Combine(packageLibraryFolder.Path, "testscript.csx");
412-
File.WriteAllText(pathToScriptFile, script);
413-
414-
var result = ScriptTestRunner.Default.Execute(pathToScriptFile);
415-
Assert.Contains("Success", result.output);
416-
}
445+
File.WriteAllText(Path.Combine(packageLibraryFolder.Path, "NuGet.Config"), nugetConfig);
417446
}
418447
}
419448
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy