MCPcopy Create free account
hub / github.com/aws/smithy-go / TestCompareValues_Document

Function TestCompareValues_Document

testing/struct_test.go:299–332  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

297}
298
299func 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
334type mockDocumentMarshaler struct {
335 p []byte

Callers

nothing calls this directly

Calls 3

CompareValuesFunction · 0.85
ErrorfMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected