Skip to content

Commit 978bcc1

Browse files
committed
chore: refactor
Signed-off-by: Ivan Ivanov <ivanivanov.ii726@gmail.com>
1 parent 2a3d5ce commit 978bcc1

1 file changed

Lines changed: 9 additions & 75 deletions

File tree

sdk/endpoint_unit_test.go

Lines changed: 9 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/stretchr/testify/require"
1212
)
1313

14-
func TestEndpoint_SetAndGetAddress(t *testing.T) {
14+
func TestEndpointSetAndGetAddress(t *testing.T) {
1515
t.Parallel()
1616

1717
endpoint := &Endpoint{}
@@ -23,7 +23,7 @@ func TestEndpoint_SetAndGetAddress(t *testing.T) {
2323
assert.Equal(t, testAddress, endpoint.GetAddress(), "GetAddress should return the set address")
2424
}
2525

26-
func TestEndpoint_SetAndGetPort(t *testing.T) {
26+
func TestEndpointSetAndGetPort(t *testing.T) {
2727
t.Parallel()
2828

2929
endpoint := &Endpoint{}
@@ -35,7 +35,7 @@ func TestEndpoint_SetAndGetPort(t *testing.T) {
3535
assert.Equal(t, testPort, endpoint.GetPort(), "GetPort should return the set port")
3636
}
3737

38-
func TestEndpoint_SetAndGetDomainName(t *testing.T) {
38+
func TestEndpointSetAndGetDomainName(t *testing.T) {
3939
t.Parallel()
4040

4141
endpoint := &Endpoint{}
@@ -47,7 +47,7 @@ func TestEndpoint_SetAndGetDomainName(t *testing.T) {
4747
assert.Equal(t, testDomain, endpoint.GetDomainName(), "GetDomainName should return the set domain name")
4848
}
4949

50-
func TestEndpoint_Validate_Success(t *testing.T) {
50+
func TestEndpointValidate(t *testing.T) {
5151
t.Parallel()
5252

5353
testCases := []struct {
@@ -78,9 +78,7 @@ func TestEndpoint_Validate_Success(t *testing.T) {
7878
}
7979

8080
for _, tc := range testCases {
81-
tc := tc
8281
t.Run(tc.name, func(t *testing.T) {
83-
t.Parallel()
8482

8583
endpoint := tc.setupFunc()
8684
err := endpoint.Validate()
@@ -90,7 +88,7 @@ func TestEndpoint_Validate_Success(t *testing.T) {
9088
}
9189
}
9290

93-
func TestEndpoint_Validate_Failure(t *testing.T) {
91+
func TestEndpointValidateFailure(t *testing.T) {
9492
t.Parallel()
9593

9694
testCases := []struct {
@@ -122,7 +120,6 @@ func TestEndpoint_Validate_Failure(t *testing.T) {
122120

123121
for _, tc := range testCases {
124122
t.Run(tc.name, func(t *testing.T) {
125-
t.Parallel()
126123

127124
endpoint := tc.setupFunc()
128125
err := endpoint.Validate()
@@ -187,9 +184,7 @@ func TestEndpointFromProtobuf(t *testing.T) {
187184
}
188185

189186
for _, tc := range testCases {
190-
tc := tc
191187
t.Run(tc.name, func(t *testing.T) {
192-
t.Parallel()
193188

194189
result := EndpointFromProtobuf(tc.serviceEndpoint)
195190

@@ -198,7 +193,7 @@ func TestEndpointFromProtobuf(t *testing.T) {
198193
}
199194
}
200195

201-
func TestEndpoint_ToProtobuf(t *testing.T) {
196+
func TestEndpointToProtobuf(t *testing.T) {
202197
t.Parallel()
203198

204199
endpoint := &Endpoint{
@@ -218,7 +213,7 @@ func TestEndpoint_ToProtobuf(t *testing.T) {
218213
assert.Equal(t, expected, result)
219214
}
220215

221-
func TestEndpoint_String(t *testing.T) {
216+
func TestEndpointString(t *testing.T) {
222217
t.Parallel()
223218

224219
testCases := []struct {
@@ -267,9 +262,7 @@ func TestEndpoint_String(t *testing.T) {
267262
}
268263

269264
for _, tc := range testCases {
270-
tc := tc
271265
t.Run(tc.name, func(t *testing.T) {
272-
t.Parallel()
273266

274267
result := tc.endpoint.String()
275268

@@ -278,26 +271,7 @@ func TestEndpoint_String(t *testing.T) {
278271
}
279272
}
280273

281-
func TestEndpoint_MethodChaining(t *testing.T) {
282-
t.Parallel()
283-
284-
endpoint := &Endpoint{}
285-
testAddress := []byte{192, 168, 1, 1}
286-
testPort := int32(8080)
287-
testDomain := "example.com"
288-
289-
result := endpoint.
290-
SetAddress(testAddress).
291-
SetPort(testPort).
292-
SetDomainName(testDomain)
293-
294-
assert.Equal(t, endpoint, result)
295-
assert.Equal(t, testAddress, endpoint.GetAddress())
296-
assert.Equal(t, testPort, endpoint.GetPort())
297-
assert.Equal(t, testDomain, endpoint.GetDomainName())
298-
}
299-
300-
func TestEndpoint_EmptyValues(t *testing.T) {
274+
func TestEndpointEmptyValues(t *testing.T) {
301275
t.Parallel()
302276

303277
endpoint := &Endpoint{}
@@ -307,47 +281,7 @@ func TestEndpoint_EmptyValues(t *testing.T) {
307281
assert.Equal(t, "", endpoint.GetDomainName())
308282
}
309283

310-
func TestEndpoint_EdgeCases(t *testing.T) {
311-
t.Parallel()
312-
313-
t.Run("EmptyAddress", func(t *testing.T) {
314-
t.Parallel()
315-
316-
endpoint := &Endpoint{}
317-
endpoint.SetAddress([]byte{})
318-
319-
assert.Equal(t, []byte{}, endpoint.GetAddress())
320-
})
321-
322-
t.Run("NilAddressAfterSet", func(t *testing.T) {
323-
t.Parallel()
324-
325-
endpoint := &Endpoint{}
326-
endpoint.SetAddress(nil)
327-
328-
assert.Nil(t, endpoint.GetAddress())
329-
})
330-
331-
t.Run("EmptyDomainName", func(t *testing.T) {
332-
t.Parallel()
333-
334-
endpoint := &Endpoint{}
335-
endpoint.SetDomainName("")
336-
337-
assert.Equal(t, "", endpoint.GetDomainName())
338-
})
339-
340-
t.Run("NegativePort", func(t *testing.T) {
341-
t.Parallel()
342-
343-
endpoint := &Endpoint{}
344-
endpoint.SetPort(-1)
345-
346-
assert.Equal(t, int32(-1), endpoint.GetPort())
347-
})
348-
}
349-
350-
func TestEndpoint_RoundTripProtobuf(t *testing.T) {
284+
func TestEndpointRoundTripProtobuf(t *testing.T) {
351285
t.Parallel()
352286

353287
originalEndpoint := &Endpoint{

0 commit comments

Comments
 (0)