Skip to content

Commit

Permalink
Test utils.JoinHostPort()
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Jul 5, 2024
1 parent 7d2a09e commit 1d69f7c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,26 @@ func TestIsUnixAddr(t *testing.T) {
}
}

func TestJoinHostPort(t *testing.T) {
subtests := []struct {
name string
host string
port int
output string
}{
{"empty", "", 0, ":0"},
{"ipv4", "192.0.2.1", 80, "192.0.2.1:80"},
{"ipv6", "2001:db8::", 443, "[2001:db8::]:443"},
{"unix", "/tmp/sock", 5665, "/tmp/sock"},
}

for _, st := range subtests {
t.Run(st.name, func(t *testing.T) {
require.Equal(t, st.output, JoinHostPort(st.host, st.port))
})
}
}

func TestChanFromSlice(t *testing.T) {
t.Run("Nil", func(t *testing.T) {
ch := ChanFromSlice[int](nil)
Expand Down

0 comments on commit 1d69f7c

Please sign in to comment.