Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tests): fix assertion for TestGetEndpoints and refactor assertion for TestKnativeSelectSplit #3951

Merged
merged 1 commit into from
May 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions internal/dataplane/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parser

import (
"fmt"
"reflect"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -4044,13 +4043,15 @@ func TestGetEndpoints(t *testing.T) {
{
Name: "default",
TargetPort: intstr.FromInt(80),
Port: 2080,
},
},
},
},
port: &corev1.ServicePort{
Name: "default",
TargetPort: intstr.FromInt(2080),
TargetPort: intstr.FromInt(80),
Port: 2080,
},
proto: corev1.ProtocolTCP,
fn: func(string, string) (*corev1.Endpoints, error) {
Expand All @@ -4076,13 +4077,15 @@ func TestGetEndpoints(t *testing.T) {
{
Name: "default",
TargetPort: intstr.FromInt(80),
Port: 2080,
},
},
},
},
port: &corev1.ServicePort{
Name: "default",
TargetPort: intstr.FromInt(2080),
TargetPort: intstr.FromInt(80),
Port: 2080,
},
proto: corev1.ProtocolTCP,
fn: func(string, string) (*corev1.Endpoints, error) {
Expand Down Expand Up @@ -4113,6 +4116,7 @@ func TestGetEndpoints(t *testing.T) {
port: &corev1.ServicePort{
Name: "default",
TargetPort: intstr.FromInt(80),
Port: 2080,
},
proto: corev1.ProtocolTCP,
fn: func(string, string) (*corev1.Endpoints, error) {
Expand Down Expand Up @@ -4351,9 +4355,7 @@ func TestGetEndpoints(t *testing.T) {
for _, testCase := range tests {
t.Run(testCase.name, func(t *testing.T) {
result := getEndpoints(logrus.New(), testCase.svc, testCase.port, testCase.proto, testCase.fn, testCase.isServiceUpstream)
if len(testCase.result) != len(result) {
t.Errorf("expected %v Endpoints but got %v", testCase.result, len(result))
}
require.Equal(t, testCase.result, result)
})
}
}
Expand Down Expand Up @@ -4489,9 +4491,8 @@ func TestKnativeSelectSplit(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := knativeSelectSplit(tt.args.splits); !reflect.DeepEqual(got, tt.want) {
t.Errorf("knativeSelectSplit() = %v, want %v", got, tt.want)
}
result := knativeSelectSplit(tt.args.splits)
require.Equal(t, tt.want, result)
})
}
}
Expand Down
Loading