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

Allow source and transform files to be read-only #17

Merged
merged 5 commits into from
Apr 27, 2018

Conversation

icnocop
Copy link
Contributor

@icnocop icnocop commented Mar 22, 2018

Fixed #16

Copy link
Member

@davilimap davilimap left a comment

Choose a reason for hiding this comment

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

A little more verification on tests.
Minor changes.

JsonTransformation transformation = new JsonTransformation(tempSourceFilePath.FilePath, this.logger);
using (Stream result = transformation.Apply(tempTransformFilePath.FilePath))
{
// succeess
Copy link
Member

Choose a reason for hiding this comment

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

Nit: spelling

JsonTransformation transformation = new JsonTransformation(tempSourceFilePath.FilePath, this.logger);
using (Stream result = transformation.Apply(tempTransformFilePath.FilePath))
{
// succeess
Copy link
Member

Choose a reason for hiding this comment

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

We need more verification for success here, ie result not null, maybe compare result to the expected result.

return;
}

if (!File.Exists(this.FilePath))
Copy link
Member

Choose a reason for hiding this comment

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

Minor, but these two checks can be shortened to:
if (File.Exists(this.FilePath)) { // Do stuff }

@icnocop
Copy link
Contributor Author

icnocop commented Apr 26, 2018

Thank you for the review, @davilimap.

I've addressed the changes you requested and also fixed the appveyor build.

Thank you.

using (JsonTextReader jsonReader = new JsonTextReader(streamReader))
{
var transformed = JObject.Load(jsonReader);
var expected = JObject.Parse(@"{
Copy link
Member

Choose a reason for hiding this comment

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

Since you renamed A, the expected result should be:
{ 'Astar': 1 }
In any case, this test doesn't need to (and probably shouldn't) verify the correctness of the transformation. You can just verify that the result stream is not null and no exceptions were recorded, like in TryTransformTest.

@davilimap
Copy link
Member

Thanks for the fix on the appveyor build.

I made another comment on the test. Since its purpose is just to verify that we can perform transforms on read-only files, I think it should be isolated from the actual transform logic, so we shouldn't be verifying the actual content of the final transform. Like in TryTransformTest, I think we should record the exceptions and verify none were thrown and also that the result stream is not null, meaning some sort of transformation occurred.

@icnocop
Copy link
Contributor Author

icnocop commented Apr 27, 2018

I've updated the code to call existing assertion routine instead of checking the results of the transformation as suggested.

Would you like me to rebase and squash the multiple commits?

Thank you.

@davilimap
Copy link
Member

Looks good, thanks for the PR! No need no squash, I'll just merge it in.

@davilimap davilimap merged commit a9bf106 into microsoft:master Apr 27, 2018
@Damodark
Copy link

Hi,

When will this be available to download as the part of Slow-Cheetah?

Best Regards,
Damodar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants