daemon/links: use gotest.tools, remove unneeded utility and duplicated test#49232
Merged
thaJeztah merged 5 commits intomoby:masterfrom Jan 8, 2025
Merged
daemon/links: use gotest.tools, remove unneeded utility and duplicated test#49232thaJeztah merged 5 commits intomoby:masterfrom
thaJeztah merged 5 commits intomoby:masterfrom
Conversation
This utility was added in 12b6083 as a replacement for nat.NewPort(), which before that patch would panic on invalid values, but was changed to return an error. Given that the utility ignores any error, and these values are fixed values for the test, let's remove it to simplify constructing the tests. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Simplify the test by testing the result, instead of manually checking specific values. This makes sure we check the actual results, and don't miss values, or ignore unexpected values. Signed-off-by: Sebastiaan van Stijn <[email protected]>
Simplify the test by testing the result, instead of manually checking specific values. This makes sure we check the actual results, and don't miss values, or ignore unexpected values. Signed-off-by: Sebastiaan van Stijn <[email protected]>
…estLinkPortRangeEnv Simplify the test by testing the result, instead of manually checking specific values. This makes sure we check the actual results, and don't miss values, or ignore unexpected values. TestLinkPortRangeEnv was added in 611a23a to test for port-ranges to produce the expected env-vars, but used the same input as TestLinkMultipleEnv. Now that we assert all env-vars produced, it became a duplicate of TestLinkMultipleEnv, so we can remove that test. Signed-off-by: Sebastiaan van Stijn <[email protected]>
thaJeztah
commented
Jan 8, 2025
Comment on lines
+35
to
+42
| expected := &Link{ | ||
| Name: "/db/docker", | ||
| ParentIP: "172.0.17.3", | ||
| ChildIP: "172.0.17.2", | ||
| Ports: []nat.Port{"6379/tcp"}, | ||
| } | ||
|
|
||
| assert.DeepEqual(t, expected, link) |
Member
Author
There was a problem hiding this comment.
FWIW; this is roughly how I arrived in this package; the Link type is not used anywhere, and it's only used as an intermediate struct to produce the env-vars to set.
I may be rewriting some code so that the scope of the package is reduced to only generating env-vars and internalise the Link type.
thaJeztah
commented
Jan 8, 2025
Comment on lines
+77
to
+78
| "DOCKER_PORT_6379_TCP_ADDR=172.0.17.2", | ||
| "DOCKER_PORT_6379_TCP_ADDR=172.0.17.2", // FIXME(thaJeztah): duplicate? |
Member
Author
There was a problem hiding this comment.
And this was a fun discovery when I rewrote the test; looks like a bug, likely introduced in #10061 resulting in the same linux/port being processed multiple times, causing duplicate env-vars.
Not problematic, as they will be ignored when creating the container, but still probably a bug.
robmry
approved these changes
Jan 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
relates to:
daemon/links: remove newPortNoError utility
This utility was added in 12b6083 as a
replacement for nat.NewPort(), which before that patch would panic on
invalid values, but was changed to return an error.
Given that the utility ignores any error, and these values are fixed values
for the test, let's remove it to simplify constructing the tests.
daemon/links: TestLinkNew: assert with gotest.tools
daemon/links: TestLinkNaming: assert with gotest.tools
Simplify the test by testing the result, instead of manually checking
specific values. This makes sure we check the actual results, and don't
miss values, or ignore unexpected values.
daemon/links: TestLinkEnv: assert with gotest.tools
Simplify the test by testing the result, instead of manually checking
specific values. This makes sure we check the actual results, and don't
miss values, or ignore unexpected values.
daemon/links: TestLinkMultipleEnv: assert with gotest.tools, remove TestLinkPortRangeEnv
Simplify the test by testing the result, instead of manually checking
specific values. This makes sure we check the actual results, and don't
miss values, or ignore unexpected values.
TestLinkPortRangeEnv was added in 611a23a
to test for port-ranges to produce the expected env-vars, but used the
same input as TestLinkMultipleEnv. Now that we assert all env-vars produced,
it became a duplicate of TestLinkMultipleEnv, so we can remove that test.
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)