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

test: added test for Processor.go functions #1124

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

satyazzz123
Copy link
Contributor

@satyazzz123 satyazzz123 commented Dec 15, 2023

test for filesystem processor.go functions

i) this test case covers a scenario where it checks if newProcessor function creates a processor instance with the given options.
ii) test for the scenario where the processFile function is able to succesfully process the file.
iii)test for scenario when processDirectory successfully processes an existing source and existing destination directory.
iv) test for sceanrio when process function succesfully processes an existing source and existing destination directory.

partly fixes #881

Copy link

Thanks for making a pull request! 😃
One of the maintainers will review and advise on the next steps.

@github-actions github-actions bot added the test label Dec 15, 2023
Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 15.15%. Comparing base (d9f7e62) to head (171948c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1124      +/-   ##
==========================================
+ Coverage   14.89%   15.15%   +0.26%     
==========================================
  Files          90       90              
  Lines        8380     8380              
==========================================
+ Hits         1248     1270      +22     
+ Misses       6809     6777      -32     
- Partials      323      333      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@satyazzz123
Copy link
Contributor Author

@seshapad @kmehant Please Review this PR.

@kmehant
Copy link
Member

kmehant commented Dec 18, 2023

Thank you for the contribution @satyazzz123

Can you add more test cases to this PR to cover other functions in this file (processor.go)?

cc @seshapad

@satyazzz123
Copy link
Contributor Author

Thank you for the contribution @satyazzz123

Can you add more test cases to this PR to cover other functions in this file (processor.go)?

cc @seshapad

Yes , I am working on other test cases as well will soon raise a PR soon covering more functions and cases

@kmehant
Copy link
Member

kmehant commented Dec 18, 2023

#1124 (comment)

Lets expand the scope of this PR (instead of creating new ones) to test complete processor.go.

@satyazzz123
Copy link
Contributor Author

#1124 (comment)

Lets expand the scope of this PR (instead of creating new ones) to test complete processor.go.

Got it will push commits to this PR itself adding more tests

@satyazzz123
Copy link
Contributor Author

@kmehant I have added some more test cases . Please have a look

Copy link
Contributor

@HarikrishnanBalagopal HarikrishnanBalagopal left a comment

Choose a reason for hiding this comment

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

Please flesh out the tests to be more meaningful. Most of the fields and callbacks are empty/nil and the tests don't actually test anything.

processor := newProcessor(mockOptions)

// Check that the returned processor is not nil
if processor == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check if the config and callbacks are preserved.

err := processor.processFile(source, destination)

// Assert the result
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix formatting


t.Run("test for the scenario where the processing of a file is successful", func(t *testing.T) {
source := "path/to/source/file.txt"
destination := "path/to/destination/file.txt"
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix formatting

err := processor.processFile(source, destination)

// Assert the result
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also check if the file was processed correctly.

@HarikrishnanBalagopal
Copy link
Contributor

related #1071

@satyazzz123 satyazzz123 changed the title test: added test for newProcessor function test: added test for Processor.go function Jan 9, 2024
@satyazzz123 satyazzz123 changed the title test: added test for Processor.go function test: added test for Processor.go functions Jan 9, 2024
@kmehant
Copy link
Member

kmehant commented Jan 16, 2024

@satyazzz123 any update on this PR referring to @HarikrishnanBalagopal's review?

@satyazzz123
Copy link
Contributor Author

@satyazzz123 any update on this PR referring to @HarikrishnanBalagopal's review?

Yes I am working on the changes right now will soon push the changes also adding some more test cases to increase test coverage for processor.go functions

@satyazzz123
Copy link
Contributor Author

There were some new tests I had added to processor.go but they were failing before I am fixing them and raising a PR. Sorry for the delay 😥

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

Successfully merging this pull request may close these issues.

test: Test the filesystem package.
3 participants