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 a7d89b8 commit 50013ae
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 @@ -171,6 +171,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 50013ae

Please sign in to comment.