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

[OneExplorer] Introduce BaseModelToCfgMap/CfgToCfgObjMap #1453

Merged
merged 2 commits into from
Nov 9, 2022

Conversation

dayo09
Copy link
Contributor

@dayo09 dayo09 commented Nov 4, 2022

This commit refactors OneStorage class
to divide its functionalities into CfgToCfgObjMap and BaseModelToCfgMap.
It includes unit tests.

ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee [email protected]


Related to #1442
From #1446
Waiting for #1452

@dayo09 dayo09 added NO MERGE 2 approvals 2 approvals required to be merged labels Nov 4, 2022
@dayo09 dayo09 force-pushed the 1102-refactor-pr branch 2 times, most recently from 23adff9 to 37d3e6b Compare November 7, 2022 01:29
This commit refactors OneStorage class
to divide its functionalities into CfgToCfgObjMap and BaseModelToCfgMap.
It includes unit tests.

ONE-vscode-DCO-1.0-Signed-off-by: Dayoung Lee <[email protected]>
@dayo09 dayo09 requested a review from a team November 7, 2022 01:41
@dayo09 dayo09 removed the NO MERGE label Nov 7, 2022
Comment on lines +72 to +75
* Update the data when cfg file's path is changed or the content is changed.
* @param type NodeType
* @param path config path to update
* @param newpath (optional) if exists, change the file path
Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot fully understand this method to review. 😓 When will this method be called without the newpath? AFAIU it will reload the ConfigObj with the exactly same path before.

Copy link
Contributor Author

@dayo09 dayo09 Nov 7, 2022

Choose a reason for hiding this comment

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

When will this method be called without the newpath?

  • When a config file is changed and onChangedFile event is triggered -> update the CfgObj (newpath === undefined) with the same old key
  • When a config file is renamed and onDidRenameFile event is triggered -> update the CfgObj (newpath !== undefined) with the new key

*The onDidRenameFiles event is not yet added to ONE Explorer, it's planned after this PR. You can see the rough idea here https://github.com/Samsung/ONE-vscode/pull/1443/files#diff-6a7e327eaf6ee1aa5232d0b8c719e823efaae072d7793421095dc0f9eb8229d5R450-R470)

@dayo09 dayo09 requested a review from yunjayh November 7, 2022 05:40
Copy link
Contributor

@yunjayh yunjayh left a comment

Choose a reason for hiding this comment

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

LGTM Thank you!

@yunjayh yunjayh requested a review from a team November 7, 2022 05:42
Comment on lines +29 to +30
BaseModelToCfgMap as _unit_test_BaseModelToCfgMap,
CfgToCfgObjMap as _unit_test_CfgToCfgObjMap,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not test-related files but they are exported as _unit_test_*, why...?

Copy link
Contributor Author

@dayo09 dayo09 Nov 9, 2022

Choose a reason for hiding this comment

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

This PR includes unit test files.

Those maps are designed to be only used within OneStorage, internally. They are not to be exported. However, to test them more deeply, it's required that the unit test file imports them. So I put _unit_test prefix to them.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see it :)
Just FYI, there are some workaround patterns such as https://stackoverflow.com/a/54116079 and https://stackoverflow.com/a/65422568.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, actually the workaround used in the links are the same to this - it's by aliasing its internal functions when exporting :-D

@@ -14,6 +14,7 @@
* limitations under the License.
*/

import {assert} from 'chai';
Copy link
Contributor

Choose a reason for hiding this comment

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

AKAIK, chai is for writing testcases.
Maybe following is what you intended?

Suggested change
import {assert} from 'chai';
import {assert} from 'assert';

Copy link
Contributor Author

@dayo09 dayo09 Nov 9, 2022

Choose a reason for hiding this comment

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

@llFreetimell

AKAIK, chai is for writing testcases.

I thought chai is more advanced assertion library, supporting BDD also.
https://www.chaijs.com/guide/styles/

I searched stackoverflow. It seems there is not exact guide about not using chai in place of assert. It seems there is no reason not to do so.

@dayo09 dayo09 requested a review from llFreetimell November 9, 2022 04:16
@llFreetimell llFreetimell merged commit 73eab1e into Samsung:main Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 approvals 2 approvals required to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants