Skip to content

Commit

Permalink
fix: fixing some misleading unit test case names (envoyproxy#4934)
Browse files Browse the repository at this point in the history
  • Loading branch information
keithfz authored Dec 17, 2024
1 parent f2641b3 commit 4cba2e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/kubernetes_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ func (service *KubernetesServiceSpec) ApplyMergePatch(old *corev1.Service) (*cor
var patchedJSON []byte
var err error

// Serialize the current deployment to JSON
// Serialize the current service to JSON
originalJSON, err := json.Marshal(old)
if err != nil {
return nil, fmt.Errorf("error marshaling original deployment: %w", err)
return nil, fmt.Errorf("error marshaling original service: %w", err)
}

switch {
Expand Down
30 changes: 17 additions & 13 deletions api/v1alpha1/validation/envoyproxy_validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ func TestValidateEnvoyProxy(t *testing.T) {
expected: true,
},
{
name: "should be invalid when service patch type is empty",
name: "should be valid when service patch is empty",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand All @@ -427,7 +427,7 @@ func TestValidateEnvoyProxy(t *testing.T) {
expected: true,
},
{
name: "should be invalid when deployment patch type is empty",
name: "should be valid when deployment patch is empty",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand Down Expand Up @@ -500,7 +500,7 @@ func TestValidateEnvoyProxy(t *testing.T) {
expected: true,
},
{
name: "should be invalid when pdb patch not set",
name: "should be invalid when pdb patch object is empty",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand All @@ -522,7 +522,7 @@ func TestValidateEnvoyProxy(t *testing.T) {
expected: false,
},
{
name: "should be invalid when pdb type not set",
name: "should be valid when pdb type not set",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand All @@ -534,14 +534,16 @@ func TestValidateEnvoyProxy(t *testing.T) {
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyPDB: &egv1a1.KubernetesPodDisruptionBudgetSpec{
Patch: &egv1a1.KubernetesPatchSpec{
Type: ptr.To(egv1a1.StrategicMerge),
Value: apiextensionsv1.JSON{
Raw: []byte("{}"),
},
},
},
},
},
},
},
expected: false,
expected: true,
},
{
name: "should be valid when hpa patch and type are empty",
Expand Down Expand Up @@ -593,7 +595,7 @@ func TestValidateEnvoyProxy(t *testing.T) {
expected: true,
},
{
name: "should be invalid when hpa patch not set",
name: "should be invalid when hpa patch object is empty",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand All @@ -615,7 +617,7 @@ func TestValidateEnvoyProxy(t *testing.T) {
expected: false,
},
{
name: "should be invalid when hpa type not set",
name: "should be valid when hpa type not set",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand All @@ -627,17 +629,19 @@ func TestValidateEnvoyProxy(t *testing.T) {
Kubernetes: &egv1a1.EnvoyProxyKubernetesProvider{
EnvoyHpa: &egv1a1.KubernetesHorizontalPodAutoscalerSpec{
Patch: &egv1a1.KubernetesPatchSpec{
Type: ptr.To(egv1a1.StrategicMerge),
Value: apiextensionsv1.JSON{
Raw: []byte("{}"),
},
},
},
},
},
},
},
expected: false,
expected: true,
},
{
name: "should invalid when patch object is empty",
name: "should invalid when deployment patch object is empty",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand All @@ -659,7 +663,7 @@ func TestValidateEnvoyProxy(t *testing.T) {
expected: false,
},
{
name: "should valid when patch type and object are both not empty",
name: "should valid when deployment patch type and object are both not empty",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand All @@ -684,7 +688,7 @@ func TestValidateEnvoyProxy(t *testing.T) {
expected: true,
},
{
name: "should valid when patch type is empty and object is not empty",
name: "should valid when deployment patch type is empty and object is not empty",
proxy: &egv1a1.EnvoyProxy{
ObjectMeta: metav1.ObjectMeta{
Namespace: "test",
Expand Down

0 comments on commit 4cba2e2

Please sign in to comment.