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

Function CompareJSONReaderBytes

testing/bytes.go:58–71  ·  view source on GitHub ↗

CompareJSONReaderBytes compares the reader containing serialized JSON document. Deserializes the JSON documents to determine if they are equal. Return an error if the two JSON documents are not equal.

(r io.Reader, expect []byte)

Source from the content-addressed store, hash-verified

56// document. Deserializes the JSON documents to determine if they are equal.
57// Return an error if the two JSON documents are not equal.
58func CompareJSONReaderBytes(r io.Reader, expect []byte) error {
59 if r == nil {
60 return fmt.Errorf("missing body")
61 }
62 actual, err := io.ReadAll(r)
63 if err != nil {
64 return fmt.Errorf("unable to read, %v", err)
65 }
66
67 if err := JSONEqual(expect, actual); err != nil {
68 return fmt.Errorf("JSON documents not equal, %v", err)
69 }
70 return nil
71}
72
73// CompareXMLReaderBytes compares the reader with expected xml byte
74func CompareXMLReaderBytes(r io.Reader, expect []byte) error {

Callers

nothing calls this directly

Calls 2

JSONEqualFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected