Skip to content

libnetwork: use errdefs and gotest.tools for asserting error-types (step 1)#49326

Merged
thaJeztah merged 8 commits intomoby:masterfrom
thaJeztah:libnetwork_use_errdefs_step1
Jan 22, 2025
Merged

libnetwork: use errdefs and gotest.tools for asserting error-types (step 1)#49326
thaJeztah merged 8 commits intomoby:masterfrom
thaJeztah:libnetwork_use_errdefs_step1

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

…ypes

Make sure these errors are properly detected by the errdefs helpers to
implement the right interface / definition.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Rewrite the test using gotest.tools and use  the errdefs helpers to assert
the right errdefs definition.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Also rename the test to TestGetHostPartIP, removing "Util" from  the name.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Also rename the test to TestGetBroadcastIP, removing "Util" from  the name.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Both net.IP and net.IPMask implement a stringer interface; use it to print
their value. While updating also removed the naked return.

Before this patch:

    cannot compute host portion ip address because ip and mask are not compatible: (net.IP{0x20, 0x1, 0xd, 0xb8, 0x20, 0x2, 0x20, 0x1, 0xff, 0xff, 0xab, 0xcd, 0xee, 0xab, 0x0, 0xcd}, net.IPMask{0xff, 0xff, 0xff, 0x0})
    cannot compute host portion ip address because ip and mask are not compatible: (net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xad, 0x20, 0x4, 0x5}, net.IPMask{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0})
    cannot compute host portion ip address because ip and mask are not compatible: (net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xad, 0x20, 0x4, 0x5}, net.IPMask{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0})

With this patch:

    cannot compute host portion ip address because ip and mask are not compatible: (2001:db8:2002:2001:ffff:abcd:eeab:cd, ffffff00)
    cannot compute host portion ip address because ip and mask are not compatible: (173.32.4.5, 000000000000000000000000ffffff00)
    cannot compute host portion ip address because ip and mask are not compatible: (173.32.4.5, 00000000000000000000ffffffffff00)

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah added status/2-code-review area/networking Networking kind/refactor PR's that refactor, or clean-up code labels Jan 22, 2025
@thaJeztah thaJeztah added this to the 28.0.0 milestone Jan 22, 2025
@thaJeztah thaJeztah self-assigned this Jan 22, 2025
@thaJeztah
Copy link
Copy Markdown
Member Author

Thx! I'll bring this one in, and open a PR with the next batch of changes related to this (trying to cut it up into sizeable PRs 🙈)

@thaJeztah thaJeztah merged commit 20a05da into moby:master Jan 22, 2025
@thaJeztah thaJeztah deleted the libnetwork_use_errdefs_step1 branch January 22, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking Networking kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants