(t *testing.T)
| 297 | } |
| 298 | |
| 299 | func TestCompareValues_Document(t *testing.T) { |
| 300 | cases := map[string]struct { |
| 301 | A, B interface{} |
| 302 | ExpectErr string |
| 303 | }{ |
| 304 | "equal": { |
| 305 | A: &mockDocumentMarshaler{[]byte("123"), nil}, |
| 306 | B: &mockDocumentMarshaler{[]byte("123"), nil}, |
| 307 | }, |
| 308 | "unequal": { |
| 309 | A: &mockDocumentMarshaler{[]byte("123"), nil}, |
| 310 | B: &mockDocumentMarshaler{[]byte("124"), nil}, |
| 311 | ExpectErr: "<root>: document values unequal", |
| 312 | }, |
| 313 | } |
| 314 | for name, c := range cases { |
| 315 | t.Run(name, func(t *testing.T) { |
| 316 | err := CompareValues(c.A, c.B) |
| 317 | |
| 318 | if len(c.ExpectErr) != 0 { |
| 319 | if err == nil { |
| 320 | t.Errorf("expect error, got none") |
| 321 | } |
| 322 | if e, a := c.ExpectErr, err.Error(); !strings.Contains(a, e) { |
| 323 | t.Errorf("expect error to contain %v, got %v", e, a) |
| 324 | } |
| 325 | return |
| 326 | } |
| 327 | if err != nil { |
| 328 | t.Errorf("expect no error, got %v", err) |
| 329 | } |
| 330 | }) |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | type mockDocumentMarshaler struct { |
| 335 | p []byte |
nothing calls this directly
no test coverage detected