simplify bytes check

This commit is contained in:
Murat Kabilov 2017-05-26 18:34:05 +02:00
parent 3ab8537b8b
commit fdde527e82
2 changed files with 7 additions and 9 deletions

View File

@ -12,7 +12,7 @@ import (
"k8s.io/client-go/pkg/api/v1"
)
var parseTime = []struct {
var parseTimeTests = []struct {
in string
out time.Time
outWeekday time.Weekday
@ -323,8 +323,8 @@ func mustParseTime(s string) time.Time {
}
func TestParseTime(t *testing.T) {
for _, tt := range parseTime {
aTime, weekday, weekdayProvided, err := ParseTime(tt.in)
for _, tt := range parseTimeTests {
aTime, weekday, weekdayProvided, err := parseTime(tt.in)
if err != nil {
if err.Error() != tt.err.Error() {
t.Errorf("ParseTime expected error: %v, got: %v", err, tt.err)
@ -387,7 +387,7 @@ func TestMarshalMaintenanceWindow(t *testing.T) {
continue
}
if bytes.Compare(s, tt.in) != 0 {
if !bytes.Equal(s, tt.in) {
t.Errorf("Expected Marshal: %s, got: %s", string(tt.in), string(s))
}
}
@ -422,7 +422,7 @@ func TestMarshal(t *testing.T) {
t.Errorf("Marshal error: %v", err)
continue
}
if bytes.Compare(m, tt.marshal) != 0 {
if !bytes.Equal(m, tt.marshal) {
t.Errorf("Marshal Postgresql expected: %s, got: %s", string(tt.marshal), string(m))
}
}
@ -437,8 +437,6 @@ func TestPostgresMeta(t *testing.T) {
if a := tt.out.GetObjectMeta(); reflect.DeepEqual(a, tt.out.Metadata) {
t.Errorf("GetObjectMeta expected: %v, got: %v", tt.out.Metadata, a)
}
return
}
}

View File

@ -33,12 +33,12 @@ func TestNamespacedNameDecode(t *testing.T) {
func TestNamespacedNameMarshal(t *testing.T) {
for _, tt := range nnTests {
var actual NamespacedName
err := actual.Decode(tt.s)
m, err := actual.MarshalJSON()
if err != nil {
t.Errorf("Marshal error: %v", err)
}
if bytes.Compare(m, tt.expectedMarshal) != 0 {
if bytes.Equal(m, tt.expectedMarshal) {
t.Errorf("Expected marshal: %v, got %#v", tt.expected, actual)
}
}