Files
tasks/common/config/localip_test.go
Alex ShtinandGitHub 8e8f1b0f7c Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00

85 lines
1.8 KiB
Go

package config
// ** This code is copied from tchannel, we would like to not take dependency on tchannel code **
import (
"net"
"testing"
"github.com/stretchr/testify/assert"
)
func TestScoreAddr(t *testing.T) {
ipv4 := net.ParseIP("10.0.1.2")
ipv6 := net.ParseIP("2001:db8:a0b:12f0::1")
tests := []struct {
msg string
iface net.Interface
addr net.Addr
want int
wantIP net.IP
}{
{
msg: "non-local up ipv4 IPNet address",
iface: net.Interface{Flags: net.FlagUp},
addr: &net.IPNet{IP: ipv4},
want: 500,
wantIP: ipv4,
},
{
msg: "non-local up ipv4 IPAddr address",
iface: net.Interface{Flags: net.FlagUp},
addr: &net.IPAddr{IP: ipv4},
want: 500,
wantIP: ipv4,
},
{
msg: "non-local up ipv4 IPAddr address, docker interface",
iface: net.Interface{
Flags: net.FlagUp,
HardwareAddr: mustParseMAC("02:42:ac:11:56:af"),
},
addr: &net.IPNet{IP: ipv4},
want: 500,
wantIP: ipv4,
},
{
msg: "non-local up ipv4 address, local MAC address",
iface: net.Interface{
Flags: net.FlagUp,
HardwareAddr: mustParseMAC("02:42:9c:52:fc:86"),
},
addr: &net.IPNet{IP: ipv4},
want: 500,
wantIP: ipv4,
},
{
msg: "non-local down ipv4 address",
iface: net.Interface{},
addr: &net.IPNet{IP: ipv4},
want: 400,
wantIP: ipv4,
},
{
msg: "non-local down ipv6 address",
iface: net.Interface{},
addr: &net.IPAddr{IP: ipv6},
want: 100,
wantIP: ipv6,
},
{
msg: "unknown address type",
iface: net.Interface{},
addr: &net.UnixAddr{Name: "/tmp/socket"},
want: -1,
},
}
for _, tt := range tests {
gotScore, gotIP := scoreAddr(tt.iface, tt.addr)
assert.Equal(t, tt.want, gotScore, tt.msg)
assert.Equal(t, tt.wantIP, gotIP, tt.msg)
}
}