MCPcopy
hub / github.com/passteque/gluetun / Test_makeAddressToDial

Function Test_makeAddressToDial

internal/healthcheck/checker_test.go:65–101  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func Test_makeAddressToDial(t *testing.T) {
66 t.Parallel()
67
68 testCases := map[string]struct {
69 address string
70 addressToDial string
71 err error
72 }{
73 "host without port": {
74 address: "test.com",
75 addressToDial: "test.com:443",
76 },
77 "host with port": {
78 address: "test.com:80",
79 addressToDial: "test.com:80",
80 },
81 "bad address": {
82 address: "test.com::",
83 err: fmt.Errorf("splitting host and port from address: address test.com::: too many colons in address"), //nolint:lll
84 },
85 }
86
87 for name, testCase := range testCases {
88 t.Run(name, func(t *testing.T) {
89 t.Parallel()
90
91 addressToDial, err := makeAddressToDial(testCase.address)
92
93 assert.Equal(t, testCase.addressToDial, addressToDial)
94 if testCase.err != nil {
95 assert.EqualError(t, err, testCase.err.Error())
96 } else {
97 assert.NoError(t, err)
98 }
99 })
100 }
101}

Callers

nothing calls this directly

Calls 5

makeAddressToDialFunction · 0.85
ErrorfMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected