Skip to content

Commit

Permalink
update from review
Browse files Browse the repository at this point in the history
  • Loading branch information
barkbay committed Jul 8, 2021
1 parent b4ed8c8 commit cdfaee0
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions test/e2e/test/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ package test
import (
"context"
"fmt"
"strings"

"github.com/go-test/deep"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -81,14 +84,8 @@ func CheckSelector(actualSelector string, expectedLabels map[string]string) erro
if err != nil {
return err
}
actualLabels := labelSelector.MatchLabels
if len(expectedLabels) != len(actualLabels) {
return fmt.Errorf("expected %d labels in selector, got %d instead", len(expectedLabels), len(actualLabels))
}
for label, expectedValue := range expectedLabels {
if actualLabels[label] != expectedValue {
return fmt.Errorf("expected selector value for label %s is %s, got %s instead", label, expectedValue, actualLabels[label])
}
if diff := deep.Equal(expectedLabels, labelSelector.MatchLabels); diff != nil {
return errors.New(strings.Join(diff, ", "))
}
return nil
}

0 comments on commit cdfaee0

Please sign in to comment.