Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Invalid Output Directory #303

Merged
merged 12 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class UserInputException : Exception
public enum ErrorMapping
{
UserInputExceptionInvalidFilePath,
UserInputExceptionInvalidOutputPath,
UserInputExceptionInvalidTestSettings,
UserInputExceptionLoginCredential,
UserInputExceptionTestConfig,
Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.PowerApps.TestEngine/TestEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ public async Task<string> RunTestAsync(FileInfo testConfigFile, string environme
_eventHandler.EncounteredException(e);
return testRunDirectory;
}
catch (DirectoryNotFoundException)
{
_eventHandler.EncounteredException(new UserInputException(UserInputException.ErrorMapping.UserInputExceptionInvalidOutputPath.ToString()));
return "InvalidOutputDirectory";
}
catch (Exception e)
{
Logger.LogError(e.Message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public class TestEngineEventHandler : ITestEngineEvents

// NOTE: Any changes to these messages need to be handled in the consuming tool's console event handler, like in pac cli tool.
// These console messages need to be considered for localization.
public static string UserInputExceptionInvalidTestSettingsMessage = " Invalid test settings specified in testconfig. For more details, check the logs.";
public static string UserAppExceptionMessage = " [Critical Error] Could not access PowerApps. For more details, check the logs.";
public static string UserInputExceptionInvalidFilePathMessage = " Invalid file path. For more details, check the logs.";
public static string UserInputExceptionInvalidOutputPathMessage = " [Critical Error]: The output directory provided is invalid.";
public static string UserInputExceptionInvalidTestSettingsMessage = " Invalid test settings specified in testconfig. For more details, check the logs.";
public static string UserInputExceptionLoginCredentialMessage = " Invalid login credential(s). For more details, check the logs.";
public static string UserInputExceptionTestConfigMessage = " Invalid test config. For more details, check the logs.";
public static string UserInputExceptionYAMLFormatMessage = " Invalid YAML format. For more details, check the logs.";

public static string UserAppExceptionMessage = " [Critical Error] Could not access PowerApps. For more details, check the logs.";

public int CasesPassed { get => _casesPassed; set => _casesPassed = value; }
public int CasesTotal { get => _casesTotal; set => _casesTotal = value; }

Expand Down Expand Up @@ -64,6 +64,9 @@ public void EncounteredException(Exception ex)
case nameof(UserInputException.ErrorMapping.UserInputExceptionYAMLFormat):
Console.WriteLine(UserInputExceptionYAMLFormatMessage);
break;
case nameof(UserInputException.ErrorMapping.UserInputExceptionInvalidOutputPath):
Console.WriteLine(UserInputExceptionInvalidOutputPathMessage);
break;
default:
Console.WriteLine($" {ex.Message}");
break;
Expand Down
6 changes: 5 additions & 1 deletion src/PowerAppsTestEngine/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@

//setting defaults for optional parameters outside RunTestAsync
var testResult = await testEngine.RunTestAsync(testPlanFile, environmentId, tenantId, outputDirectory, domain, queryParams);
Console.WriteLine($"Test results can be found here: {testResult}");
if (testResult != "InvalidOutputDirectory")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In PAC CLI >> when we update the TE version with this fix included, reminder to make this change there.

{
Console.WriteLine($"Test results can be found here: {testResult}");
}

}
catch (Exception ex)
{
Expand Down
Loading