Files
gluetun/internal/portforward/service/helpers_test.go
Quentin McGaw abe9dcbe33 chore(lint): add new linters and update codebase
- add canonicalheader
- add copyloopvar
- add fatcontext
- add intrange
2024-10-11 18:28:00 +00:00

43 lines
718 B
Go

package service
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_portsToString(t *testing.T) {
t.Parallel()
testCases := map[string]struct {
ports []uint16
s string
}{
"no_port": {
s: "no port forwarded",
},
"one_port": {
ports: []uint16{123},
s: "port forwarded is 123",
},
"two_ports": {
ports: []uint16{123, 456},
s: "ports forwarded are 123 and 456",
},
"three_ports": {
ports: []uint16{123, 456, 789},
s: "ports forwarded are 123, 456 and 789",
},
}
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
t.Parallel()
s := portsToString(testCase.ports)
assert.Equal(t, testCase.s, s)
})
}
}