-
Notifications
You must be signed in to change notification settings - Fork 52
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 unit tests to common package for allowedValues change #641
base: main
Are you sure you want to change the base?
Conversation
@@ -213,7 +213,7 @@ private CodeTypeDeclaration GenerateEnumStruct(MetricType type) | |||
allowedValue.Replace(" ", "_").ToPascalCase().Replace(".", "").Replace("-", "")) | |||
{ | |||
InitExpression = new CodeObjectCreateExpression(type.GetGeneratedTypeName(), |
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.
For C# we converted the "key" but not the "value" to get rid of spaces. This was an oversight and testing of course caught this.
Thanks for pushing for testing.
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.
Were any Toolkits released with spaces in the values? This change would create a discrepancy in emitted values across Toolkit versions.
Why not change the definition data to remove the spaces? I don't understand why the values cannot contain spaces.
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.
There were spaces deployed this week. But we can revert this quickly as our slack discussion aligns with this being better for backend ingestion now and in the future.
telemetry/csharp/AwsToolkit.Telemetry.Events.Tests/GeneratedCodeTests.cs
Show resolved
Hide resolved
Assert.True(datum.Metadata.ContainsKey("codeTransformSessionId")); | ||
Assert.Equal("test-session-id", datum.Metadata["codeTransformSessionId"]); | ||
Assert.True(datum.Metadata.ContainsKey("codeTransformPreValidationError")); | ||
Assert.Equal("No_Java_project_found", datum.Metadata["codeTransformPreValidationError"]); |
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.
Strictly assert the new change/value here.
@@ -86,7 +86,7 @@ private fun FileSpec.Builder.generateTelemetryEnumType(item: TelemetryMetricType | |||
item.allowedValues!!.forEach { enumValue -> | |||
enum.addEnumConstant( | |||
enumValue.toString().replace(Regex("\\s"), "_").toTypeFormat(), TypeSpec.anonymousClassBuilder() |
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.
For Kotlin we converted the "key" but not the "value" to get rid of spaces. This was an oversight and testing of course caught this.
Thanks for pushing for testing.
/retryBuilds |
- revert value conversion from _ and just conver key - update definition for preValidation - fix unit tests
…olkit-common into nardeck/add-unit-tests
public enum class TestAllowedValues( | ||
private val `value`: String, | ||
) { | ||
TestSpacesAreReplaced("test spaces are replaced"), |
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.
Key is converted, but NOT the value. In general the advice was to avoid spaces for values.
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.
I would expect this not be a breaking change, since no other allowedValues
have spaces other than the values my team introduced this week. This means the enum keys will only change for our team.
"Only Maven projects supported", | ||
"Empty project", | ||
"Non SSO login", | ||
"Project running on backend" |
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.
Update the values to NOT use spaces.
/retrybuilds |
/retryBuilds |
Kotlin build failing fixed here -> https://github.com/aws/aws-toolkit-common/pull/646/files I believe this current change WILL be a breaking changes for anyone who pulls it in and should be separate from the change above. Ideally, once this change is deployed my team can fix the breaking changes (which are for Elastic gumby/ amazon q code transform) intelliJ and vscode instances. |
@damntrecky this PR contains two separate changes:
These need to be split into two separate PRs. If we need to investigate a regression, or revert a change, this PR as-is makes the repo harder to manage. The enum values update is needed sooner than the validation update. Please create a separate PR with just that change. Once that is merged in, this PR can be revisited in order to handle the testing (which is less urgent, as we won't have enum values containing spaces). |
@@ -217,6 +217,41 @@ public void RecordMetricWithNewTransform() | |||
Assert.Single(datum.Metadata); | |||
} | |||
|
|||
/// <summary> |
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.
Test to make sure allowedValues
with spaces converts the key properly and make sure the allowedValue -> value has spaces for now.
Although its recommended to NOT have spaces in the values, the build should not fail and have consistent behavior across environments
@@ -217,6 +217,41 @@ public void RecordMetricWithNewTransform() | |||
Assert.Single(datum.Metadata); | |||
} | |||
|
|||
/// <summary> | |||
/// RecordCodeTransformIsDoubleClickedToTriggerInvalidProject was chosen as a sample call that has a | |||
/// CodeTransformPreValidationError for allowedValues which have spaces in the values that |
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.
CodeTransformPreValidationError
values no longer have spaces, does the comment need to be updated?
Problem
We rushed out a fix yesterday (#638) because there were
allowedValues
withspaces in the values
and this wasn't supported by the build here. We didn't add unit tests for the fix to convert spaces to_
underscoresSolution
Unfortunately it looks like for Kotlin and C# the
allowedValues
enum, or output metdata key WAS converted, but the value itself was NOT converted to have_
underscores.This PR fixes that and adds unit tests for all three languages. I also updated the README for each section as it might not be obvious for developers on how to run the tests for each language. Especially if they are not familiar with that language.
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.