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

Refactor BFS tests to use gomega #236

Merged

Conversation

c0d1ngm0nk3y
Copy link
Contributor

@c0d1ngm0nk3y c0d1ngm0nk3y commented Sep 29, 2023

Fixes #234

Summary

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

@c0d1ngm0nk3y
Copy link
Contributor Author

@matejvasek As you are the original author of these tests, some feedback would be great if I understood them right. Note that it is not finished yet, e.g. I have to better understand them to name things.

@matejvasek
Copy link
Contributor

matejvasek commented Sep 29, 2023

@c0d1ngm0nk3y
I do not understand this part:

errOurs := fsutil.Walk(root, createWalkFn(&ourFiles))
Expect(errOurs).NotTo(HaveOccurred())

errTheirs := filepath.Walk(root, createWalkFn(&theirFiles))
Expect(errTheirs).NotTo(HaveOccurred())

How is it equivalent to:

if (ourFiles == nil) != (theirsFiles == nil) {
    t.Errorf("errors does not match, actual error: %#v, expected error: %#v", errOurs, errTheirs)
}

Maybe slightly better condition would be !errors.Is(errOurs, errTheirs) && !errors.Is(errTheirs, errOurs) or maybe errors.Unwrap(errOurs) != errors.Unwrap(errTheirs).

The point is to verify that our and stdlib walk func return same error, not that error is nil.
Speaking of which: would you mind adding a test similar to "non-existent root folder" but whit walkFn that propagates error?

@dmikusa dmikusa added type:task A general task semver:patch A change requiring a patch version bump labels Sep 29, 2023
@c0d1ngm0nk3y
Copy link
Contributor Author

How is it equivalent to:

It is not at all. That is right. The point is that I didn't understand that part at all. It is exactly one test case, right? So either there are errors in both cases or not. It was used in 2 test cases and both do not return an error, so this was kind of pointless, imho.

Or did I miss something?

Speaking of which: would you mind adding a test similar to "non-existent root folder" but whit walkFn that propagates error?

When simplifying the code like this, I had also the feeling that this is missing. I will try to add.

@matejvasek
Copy link
Contributor

It was used in 2 test cases and both do not return an error, so this was kind of pointless, imho.

Originally that code should have been common for multiple parametrized tests, some of them were supposed to return error. In particular "non-existent root folder" test should have used error propagating walk function but mistakenly I used error masking walk function.

@c0d1ngm0nk3y c0d1ngm0nk3y marked this pull request as ready for review October 2, 2023 06:34
@c0d1ngm0nk3y c0d1ngm0nk3y requested a review from a team as a code owner October 2, 2023 06:34
Copy link
Member

@anthonydahanne anthonydahanne left a comment

Choose a reason for hiding this comment

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

Hello!
I suggest you use consts, when possible, extract the function from the before and explain the createTestDir function

Let me know if that makes sense!

internal/fsutil/walk_test.go Outdated Show resolved Hide resolved
internal/fsutil/walk_test.go Outdated Show resolved Hide resolved
internal/fsutil/walk_test.go Outdated Show resolved Hide resolved
internal/fsutil/walk_test.go Outdated Show resolved Hide resolved
internal/fsutil/walk_test.go Outdated Show resolved Hide resolved
internal/fsutil/walk_test.go Show resolved Hide resolved
@c0d1ngm0nk3y c0d1ngm0nk3y force-pushed the bfs-use-gomega branch 2 times, most recently from a9f107c to defefe8 Compare October 13, 2023 08:27
@c0d1ngm0nk3y
Copy link
Contributor Author

@anthonydahanne I think I have addressed your comments. Can we get this merged? Just let me know if I oversaw something.

Co-authored-by: Anthony Dahanne <anthony.dahanne@gmail.com>
Signed-off-by: Ralf Pannemans <ralf.pannemans@sap.com>
@dmikusa
Copy link
Contributor

dmikusa commented Oct 19, 2023

Looks good to me. ASCII diagram for the win!

@c0d1ngm0nk3y can you update this one more time? Thanks

@anthonydahanne anthonydahanne merged commit bcb52de into paketo-buildpacks:main Oct 23, 2023
4 checks passed
@anthonydahanne
Copy link
Member

I rebased on my local fork; everything went fine, so I went ahead and did it here

@c0d1ngm0nk3y c0d1ngm0nk3y deleted the bfs-use-gomega branch October 27, 2023 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch A change requiring a patch version bump type:task A general task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert internal test suite
4 participants