simplify bytes check
This commit is contained in:
		
							parent
							
								
									3ab8537b8b
								
							
						
					
					
						commit
						fdde527e82
					
				|  | @ -12,7 +12,7 @@ import ( | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var parseTime = []struct { | var parseTimeTests = []struct { | ||||||
| 	in                 string | 	in                 string | ||||||
| 	out                time.Time | 	out                time.Time | ||||||
| 	outWeekday         time.Weekday | 	outWeekday         time.Weekday | ||||||
|  | @ -323,8 +323,8 @@ func mustParseTime(s string) time.Time { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func TestParseTime(t *testing.T) { | func TestParseTime(t *testing.T) { | ||||||
| 	for _, tt := range parseTime { | 	for _, tt := range parseTimeTests { | ||||||
| 		aTime, weekday, weekdayProvided, err := ParseTime(tt.in) | 		aTime, weekday, weekdayProvided, err := parseTime(tt.in) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			if err.Error() != tt.err.Error() { | 			if err.Error() != tt.err.Error() { | ||||||
| 				t.Errorf("ParseTime expected error: %v, got: %v", err, tt.err) | 				t.Errorf("ParseTime expected error: %v, got: %v", err, tt.err) | ||||||
|  | @ -387,7 +387,7 @@ func TestMarshalMaintenanceWindow(t *testing.T) { | ||||||
| 			continue | 			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)) | 			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) | 			t.Errorf("Marshal error: %v", err) | ||||||
| 			continue | 			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)) | 			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) { | 		if a := tt.out.GetObjectMeta(); reflect.DeepEqual(a, tt.out.Metadata) { | ||||||
| 			t.Errorf("GetObjectMeta expected: %v, got: %v", tt.out.Metadata, a) | 			t.Errorf("GetObjectMeta expected: %v, got: %v", tt.out.Metadata, a) | ||||||
| 		} | 		} | ||||||
| 
 |  | ||||||
| 		return |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -33,12 +33,12 @@ func TestNamespacedNameDecode(t *testing.T) { | ||||||
| func TestNamespacedNameMarshal(t *testing.T) { | func TestNamespacedNameMarshal(t *testing.T) { | ||||||
| 	for _, tt := range nnTests { | 	for _, tt := range nnTests { | ||||||
| 		var actual NamespacedName | 		var actual NamespacedName | ||||||
| 		err := actual.Decode(tt.s) | 
 | ||||||
| 		m, err := actual.MarshalJSON() | 		m, err := actual.MarshalJSON() | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Errorf("Marshal error: %v", err) | 			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) | 			t.Errorf("Expected marshal: %v, got %#v", tt.expected, actual) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue