Skip to content

Commit ba5d296

Browse files
committed
fix: resolve testing issues
1 parent a2b49ef commit ba5d296

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

tests/Flowthru.Tests.Templates/TemplateIntegrationTests.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@ private static IEnumerable<TemplateProject> GetAllTemplates()
2727
[OneTimeSetUp]
2828
public static void InstallTemplate()
2929
{
30-
// Find the repository root (navigate up from the test assembly location)
30+
// Walk up from the assembly location looking for nx.json (workspace root marker).
31+
// A fixed-depth traversal breaks when the output path depth changes (e.g. when
32+
// a Configuration segment is added to BaseOutputPath in Directory.Build.props).
3133
var assemblyPath = typeof(TemplateIntegrationTests).Assembly.Location;
32-
var testsDir = Path.GetDirectoryName(assemblyPath);
33-
var repoRoot = Path.GetFullPath(Path.Combine(testsDir!, "..", "..", "..", ".."));
34+
var dir = Path.GetDirectoryName(assemblyPath);
35+
while (dir != null && !File.Exists(Path.Combine(dir, "nx.json")))
36+
dir = Path.GetDirectoryName(dir);
3437

35-
_templateInstallPath = Path.Combine(repoRoot, "examples", "starter");
38+
if (dir == null)
39+
throw new DirectoryNotFoundException("Could not locate workspace root (nx.json not found).");
40+
41+
_templateInstallPath = Path.Combine(dir, "examples", "starter");
3642

3743
if (!Directory.Exists(_templateInstallPath))
3844
{

tests/Flowthru.Tests.Templates/_Infrastructure/TemplateTestRunner.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ public async Task<TemplateTestResult> GenerateAndRunAsync()
106106
Directory.CreateDirectory(parentDir);
107107
}
108108

109+
// Write NuGet.Config into parentDir BEFORE `dotnet new` so that the
110+
// implicit restore during template instantiation resolves Flowthru*
111+
// from the local dist/packages feed rather than nuget.org (where the
112+
// current in-development version is not yet published).
113+
WriteLocalNuGetConfig(parentDir);
114+
109115
// Clean up any existing project directory
110116
if (Directory.Exists(_project.GeneratedPath))
111117
{

0 commit comments

Comments
 (0)