Skip to content

Commit 640b052

Browse files
committed
Add e2e test
1 parent 785b10b commit 640b052

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

src/AppInstallerCLIE2ETests/ConfigureCommand.cs

+18
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,24 @@ public void TestFileResourceSchema()
305305
Assert.AreEqual(1, lines.Length);
306306
}
307307

308+
/// <summary>
309+
/// Simple test to confirm that a resource with a module specified can be discovered in a local repository that doesn't support resource discovery.
310+
/// </summary>
311+
[Test]
312+
public void ConfigureFromTestRepo_DSCv3()
313+
{
314+
TestCommon.EnsureModuleState(Constants.SimpleTestModuleName, present: true, repository: Constants.TestRepoName);
315+
this.DeleteResourceArtifacts();
316+
317+
var result = TestCommon.RunAICLICommand(CommandAndAgreementsAndVerbose, TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo_DSCv3.yml"));
318+
Assert.AreEqual(0, result.ExitCode);
319+
320+
// The configuration creates a file next to itself with the given contents
321+
string targetFilePath = TestCommon.GetTestDataFile("Configuration\\Configure_TestRepo.txt");
322+
FileAssert.Exists(targetFilePath);
323+
Assert.AreEqual("Contents!", File.ReadAllText(targetFilePath));
324+
}
325+
308326
private void DeleteResourceArtifacts()
309327
{
310328
// Delete all .txt files in the test directory; they are placed there by the tests

src/AppInstallerCLIE2ETests/Helpers/TestCommon.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,11 @@ public static void EnsureModuleState(string moduleName, bool present, string rep
848848
pwsh.PowerShell.AddParameter("Repository", repository);
849849
}
850850

851-
if (location == TestModuleLocation.AllUsers)
851+
if (location == TestModuleLocation.CurrentUser)
852+
{
853+
pwsh.PowerShell.AddParameter("Scope", "CurrentUser");
854+
}
855+
else if (location == TestModuleLocation.AllUsers)
852856
{
853857
pwsh.PowerShell.AddParameter("Scope", "AllUsers");
854858
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json
2+
metadata:
3+
winget:
4+
processor: dscv3
5+
resources:
6+
- name: Test File
7+
type: xE2ETestResource/E2EFileResource
8+
properties:
9+
Path: ${WinGetConfigRoot}\Configure_TestRepo.txt
10+
Content: Contents!

0 commit comments

Comments
 (0)