Skip to content

Conversation

@kolyshkin
Copy link
Collaborator

See individual commits for details. Originally part of #159.

First, make capability_test.go a separate package so we are limited to
testing the external API (as opposed to e.g. state_linux_test.go in
which we test internal stuff as well).

Second, streamline the linux/non-linux code so it's easier to read and
copy/paste (in general, we only want to check that non-linux functions
can be called and return an error).

Third, change some non-fatal errors to use t.Errorf.

Fourth, use want/got everywhere in error messages, and add more context
to some errors.

Nothing here is critical or makes any noticeable impact on tests.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This makes it slightly less cryptic (in particular, replacing a literal
tab with "\t"), and also silences this codespell warning:

> ./capability/capability_linux.go:311: nd ==> and, 2nd

While at it, add a simple test for the method.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin mentioned this pull request Sep 27, 2024
@kolyshkin kolyshkin requested a review from thaJeztah September 27, 2024 01:36
@kolyshkin kolyshkin marked this pull request as ready for review September 27, 2024 01:37
@kolyshkin kolyshkin requested a review from tianon September 27, 2024 01:37
t.Fatal(runtime.GOOS, ": want error, got nil")
}
return
case "linux":
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I like it that you can have default as the first case in switch; it improves readability in here (otherwise I would have to add a comment saying "Below is linux-only stuff").

@kolyshkin
Copy link
Collaborator Author

@thaJeztah @tianon PTAL 🙏

I have some more changes that depend on these.

@tianon tianon merged commit aa7aee5 into moby:main Oct 9, 2024
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