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

Chore: spurious helpers test cleanup #3729

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

apostasie
Copy link
Contributor

Remove dependency on misplaced helper CreateBuildContext for next-gen tests (use data.TempDir(), assert in the test).

@apostasie apostasie changed the title Chore: test cleanup Chore: spurious helpers test cleanup Dec 4, 2024
@apostasie apostasie marked this pull request as ready for review December 4, 2024 05:45
Comment on lines +148 to +150
buildCtx := data.TempDir()
err := os.WriteFile(filepath.Join(buildCtx, "Dockerfile"), []byte(dockerfile), 0o600)
assert.NilError(helpers.T(), err)
Copy link
Member

Choose a reason for hiding this comment

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

why we cannot use the helper directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The helper is misplaced under /cmd (like a bunch of others that should also be moved to pkg/testing or removed). It is calling t.TempDir() every time it is being called, creating a new separate temporary directory at each invocation, and buries trivial logic away from the test - for the benefit of replacing 3 lines for 1.

I do not think it is worth it. If folks here prefer to keep a helper, we should copy it over to pkg/test and change the signature of the function to at least allow passing data and helpers so that is uses data.TempDir and helpers.T instead.

Copy link
Contributor Author

@apostasie apostasie Dec 4, 2024

Choose a reason for hiding this comment

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

(I say "copy it over" because a bunch of legacy tests are still dependent on the existing helper and would not be able to use the new one until rewritten)

@apostasie apostasie requested a review from djdongjin December 6, 2024 19:28
@djdongjin djdongjin added this to the v2.0.2 milestone Dec 6, 2024
@djdongjin djdongjin merged commit f3191c4 into containerd:main Dec 6, 2024
30 checks passed
@apostasie
Copy link
Contributor Author

Thanks @djdongjin

Appreciate the review.

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

Successfully merging this pull request may close these issues.

2 participants