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

Improve file_helper implementation #604

Open
sdvendramini opened this issue Feb 14, 2025 · 0 comments
Open

Improve file_helper implementation #604

sdvendramini opened this issue Feb 14, 2025 · 0 comments
Assignees
Labels

Comments

@sdvendramini
Copy link
Member

The implementation should be improved by separating, for each target (FileIO and Filesystem), the functions that are purely wrappers from those that add logic.

This can be done as follows:

../common/file_helper/
├── CMakeLists.txt
├── file_io
│   ├── include
│   │   ├── file_io_utils.hpp
│   │   ├── file_io_wrapper.hpp
│   │   ├── ifile_io_utils.hpp
│   │   └── ifile_io_wrapper.hpp
│   ├── src
│   │   ├── file_io_utils.cpp
│   │   └── file_io_wrapper.cpp
│   └── tests
│       ├── CMakeLists.txt
│       ├── file_io_utils_test.cpp
│       ├── file_io_wrapper_test.cpp
│       └── mocks
│           ├── file_io_utils.hpp
│           └── file_io_wrapper.hpp
└── filesystem
    ├── include
    │   ├── filesystem_utils.hpp
    │   ├── filesystem_wrapper.hpp
    │   ├── ifilesystem_utils.hpp
    │   └── ifilesystem_wrapper.hpp
    ├── src
    │   ├── filesystem_utils.cpp
    │   └── filesystem_wrapper.cpp
    └── tests
        ├── CMakeLists.txt
		├── filesystem_utils_test.cpp
        ├── filesystem_wrapper_test.cpp
        └── mocks
            ├── mock_filesystem_utils.hpp
        	└── mock_filesystem_wrapper.hpp

This approach makes the code more modular, allowing file_helper functions that contain logic to be tested using the same library's wrapper mocks, thus avoiding duplicate mocks.

Keep in mind that there are some files where filesystem_wrapper functions might be used, such as in file_op.c. Adding the necessary wrappers (e.g., FileSize, w_copy_file, etc.).

The implementation of tests that manipulate the real filesystem should be improved by using these mocks, for example in the instance_handler tests and filesystem_wrapper tests.

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

No branches or pull requests

1 participant