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 tests for delta.go functions #1127

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

Conversation

satyazzz123
Copy link
Contributor

@satyazzz123 satyazzz123 commented Jan 3, 2024

test for delta.go functions

i) this test scenario covers the creation of source and destination directory and successful execution of GenerateDelta function.
ii)this test covers the scenario for the presence of a modifications file and its content after calling the GenerateDelta function.
iii) this test covers the scenario where generateDeltaAdditionCallBack correctly replicates a source file to the additions directory based on the provided configuration and if the replicated file is created in the expected location.

partly fixes #881

Copy link

github-actions bot commented Jan 3, 2024

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 Jan 3, 2024
Copy link

codecov bot commented Jan 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 15.47%. Comparing base (d9f7e62) to head (c48391b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1127      +/-   ##
==========================================
+ Coverage   14.89%   15.47%   +0.58%     
==========================================
  Files          90       90              
  Lines        8380     8380              
==========================================
+ Hits         1248     1297      +49     
+ Misses       6809     6744      -65     
- Partials      323      339      +16     

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

@satyazzz123
Copy link
Contributor Author

@seshapad @kmehant I have raised a PR. Please have a look

Copy link
Member

@kmehant kmehant left a comment

Choose a reason for hiding this comment

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

Thanks @satyazzz123, Appreciate your contributions.

Would you like to cover other functions in the delta.go file in this PR?

I will review and merge other PRs ASAP. Thank you.

@satyazzz123
Copy link
Contributor Author

Thanks @satyazzz123, Appreciate your contributions.

Would you like to cover other functions in the delta.go file in this PR?

I will review and merge other PRs ASAP. Thank you.

Yes I will cover other functions in this PR as well and add some more cases too for delta.go .

t.Fatalf("Failed to create destination directory: %v", err)
}

err = GenerateDelta(sourceDir, destinationDir, tempDir)
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the contents of the destinationDir after the function executes.

}

// Check for modifications file
modificationsFilePath := filepath.Join(tempDir, "modifications", "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.

Also add a check for the contents of the destinationDir after the function executes.


// Check for modifications file
modificationsFilePath := filepath.Join(tempDir, "modifications", "file.txt")
if _, err := os.Stat(modificationsFilePath); os.IsNotExist(err) {
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 the contents of the file.

t.Errorf("Unexpected error during generateDeltaAdditionCallBack: %v", err)
}

replicatedFilePath := filepath.Join(tempDir, additionsDir, "newfile.txt")
Copy link
Contributor

Choose a reason for hiding this comment

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

Also add a check for the contents of the destinationDir after the function executes.

}

replicatedFilePath := filepath.Join(tempDir, additionsDir, "newfile.txt")
if _, err := os.Stat(replicatedFilePath); os.IsNotExist(err) {
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 the contents of the file.

@satyazzz123
Copy link
Contributor Author

@HarikrishnanBalagopal I have addressed the requested changes . Please have a look. Thank you

@satyazzz123 satyazzz123 requested a review from kmehant January 9, 2024 13:30
Signed-off-by: satyazzz123 <beherasatyajit716@gmail.com>
Signed-off-by: satyazzz123 <beherasatyajit716@gmail.com>
Signed-off-by: satyazzz123 <beherasatyajit716@gmail.com>
Signed-off-by: satyazzz123 <beherasatyajit716@gmail.com>
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