-
Notifications
You must be signed in to change notification settings - Fork 490
Add version to test tool #1969
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
Add version to test tool #1969
Changes from 1 commit
e992386
0885b62
1293a93
5aced83
1efc6bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Projects": [ | ||
{ | ||
"Name": "Amazon.Lambda.TestTool", | ||
"Type": "Patch", | ||
"ChangelogMessages": [ | ||
"Add --version switch to allow integrators to check what version is installed" | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,6 +2,7 @@ | |||
// SPDX-License-Identifier: Apache-2.0 | ||||
|
||||
using System.Diagnostics; | ||||
using System.Text.Json; | ||||
using Amazon.Lambda.TestTool.Commands.Settings; | ||||
using Amazon.Lambda.TestTool.Extensions; | ||||
using Amazon.Lambda.TestTool.Models; | ||||
|
@@ -28,6 +29,12 @@ public override async Task<int> ExecuteAsync(CommandContext context, RunCommandS | |||
{ | ||||
try | ||||
{ | ||||
if (settings.PrintVersionInfo) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add a unit test to Line 17 in 8c1705f
Also as a side note, do we want to enforce unit test coverage for future PRs as a check? What do we do for other projects that we have? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was being reluctant adding a mocking layer around stdout so I could reliable unit test this. Turns out we are already mocking stdout with |
||||
{ | ||||
PrintVersionInfo(); | ||||
return CommandReturnCodes.Success; | ||||
} | ||||
|
||||
EvaluateEnvironmentVariables(settings); | ||||
|
||||
if (!settings.LambdaEmulatorPort.HasValue && !settings.ApiGatewayEmulatorPort.HasValue) | ||||
|
@@ -101,6 +108,15 @@ public override async Task<int> ExecuteAsync(CommandContext context, RunCommandS | |||
} | ||||
} | ||||
|
||||
private void PrintVersionInfo() | ||||
{ | ||||
Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter(Console.OpenStandardOutput()); | ||||
utf8JsonWriter.WriteStartObject(); | ||||
utf8JsonWriter.WriteString("version", Utilities.Utils.DetermineToolVersion()); | ||||
utf8JsonWriter.WriteEndObject(); | ||||
utf8JsonWriter.Flush(); | ||||
} | ||||
|
||||
private void EvaluateEnvironmentVariables(RunCommandSettings settings) | ||||
{ | ||||
var environmentVariables = environmentManager.GetEnvironmentVariables(); | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you missed updating the changelog