-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Rename AcquireJobRequest::StreamID to AcquireJobRequest::JobMessageID #2547
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
Merged
+72
−5
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cd94fc4
Rename AcquireJobRequest::StreamID to AcquireJobRequest::JobMessageID…
jww3 293e6ad
appeased the linter
jww3 a3a637a
Added unit tests to prove AcquireJobRequest serialization/deserializa…
jww3 705a3cd
Update AcquireJobRequestL0.cs
jww3 ce5f49a
Incorporated PR Feedback.
jww3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
| using System.Collections.Generic; | ||
| using System.Runtime.Serialization; | ||
| using GitHub.DistributedTask.WebApi; | ||
|
|
||
| namespace GitHub.Actions.RunService.WebApi | ||
| { | ||
| [DataContract] | ||
| public class AcquireJobRequest | ||
| { | ||
| [DataMember(Name = "jobMessageId", EmitDefaultValue = false)] | ||
| public string JobMessageId { get; set; } | ||
|
|
||
| // This field will be removed in an upcoming Runner release. | ||
| // It's left here temporarily to facilitate the transition to the new field name, JobMessageId. | ||
| [DataMember(Name = "streamId", EmitDefaultValue = false)] | ||
| public string StreamID { get; set; } | ||
| public string StreamId { get; set; } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Runtime.Serialization.Json; | ||
| using System.Text; | ||
| using Xunit; | ||
|
|
||
| namespace GitHub.Actions.RunService.WebApi.Tests; | ||
|
|
||
| public sealed class AcquireJobRequestL0 | ||
| { | ||
|
|
||
| [Fact] | ||
| [Trait("Level", "L0")] | ||
| [Trait("Category", "Common")] | ||
| public void VerifySerialization() | ||
| { | ||
| var jobMessageId = "1526919030369-33"; | ||
| var request = new AcquireJobRequest | ||
| { | ||
| JobMessageId = jobMessageId, | ||
| StreamId = jobMessageId | ||
| }; | ||
| var serializer = new DataContractJsonSerializer(typeof(AcquireJobRequest)); | ||
| using var stream = new MemoryStream(); | ||
| serializer.WriteObject(stream, request); | ||
|
|
||
| stream.Position = 0; | ||
| using var reader = new StreamReader(stream, Encoding.UTF8); | ||
| string json = reader.ReadToEnd(); | ||
| string expected = DoubleQuotify(string.Format("{{'jobMessageId':'{0}','streamId':'{0}'}}", request.JobMessageId)); | ||
| Assert.Equal(expected, json); | ||
|
|
||
| } | ||
|
|
||
| [Fact] | ||
| [Trait("Level", "L0")] | ||
| [Trait("Category", "Common")] | ||
| public void VerifyDeserialization() | ||
| { | ||
| var serializer = new DataContractJsonSerializer(typeof(AcquireJobRequest)); | ||
| var variations = new Dictionary<string, string>() | ||
| { | ||
| ["{'streamId': 'legacy', 'jobMessageId': 'new-1'}"] = "new-1", | ||
| ["{'jobMessageId': 'new-2', 'streamId': 'legacy'}"] = "new-2", | ||
| ["{'jobMessageId': 'new-3'}"] = "new-3" | ||
| }; | ||
|
|
||
| foreach (var (source, expected) in variations) | ||
| { | ||
| using var stream = new MemoryStream(); | ||
| stream.Write(Encoding.UTF8.GetBytes(DoubleQuotify(source))); | ||
| stream.Position = 0; | ||
| var recoveredRecord = serializer.ReadObject(stream) as AcquireJobRequest; | ||
| Assert.NotNull(recoveredRecord); | ||
| Assert.Equal(expected, recoveredRecord.JobMessageId); | ||
| } | ||
| } | ||
|
|
||
| private static string DoubleQuotify(string text) | ||
| { | ||
| return text.Replace('\'', '"'); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.