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

Function TestXMLNodeDecoder_Token

encoding/xml/xml_decoder_test.go:12–114  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestXMLNodeDecoder_Token(t *testing.T) {
13 cases := map[string]struct {
14 responseBody io.Reader
15 expectedStartElement xml.StartElement
16 expectedDone bool
17 expectedError string
18 }{
19 "simple success case": {
20 responseBody: bytes.NewReader([]byte(`<Response>abc</Response>`)),
21 expectedStartElement: xml.StartElement{
22 Name: xml.Name{
23 Local: "",
24 },
25 },
26 expectedDone: true,
27 },
28 "no value": {
29 responseBody: bytes.NewReader([]byte(`<Response></Response>`)),
30 expectedDone: true,
31 },
32 "empty body": {
33 responseBody: bytes.NewReader([]byte(``)),
34 expectedError: "EOF",
35 },
36 "with indentation": {
37 responseBody: bytes.NewReader([]byte(` <Response><Struct>abc</Struct></Response>`)),
38 expectedStartElement: xml.StartElement{
39 Name: xml.Name{
40 Local: "Struct",
41 },
42 Attr: []xml.Attr{},
43 },
44 },
45 "with comment and indentation": {
46 responseBody: bytes.NewReader([]byte(`<!--comment--> <Response><Struct>abc</Struct></Response>`)),
47 expectedStartElement: xml.StartElement{
48 Name: xml.Name{
49 Local: "Struct",
50 },
51 Attr: []xml.Attr{},
52 },
53 },
54 "attr with namespace": {
55 responseBody: bytes.NewReader([]byte(`<Response><Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CanonicalUser"></Grantee></Response>`)),
56 expectedStartElement: xml.StartElement{
57 Name: xml.Name{
58 Local: "Grantee",
59 },
60 Attr: []xml.Attr{
61 {
62 Name: xml.Name{
63 Space: "xmlns",
64 Local: "xsi",
65 },
66 Value: "http://www.w3.org/2001/XMLSchema-instance",
67 },
68 {
69 Name: xml.Name{

Callers

nothing calls this directly

Calls 4

FetchRootElementFunction · 0.85
WrapNodeDecoderFunction · 0.85
TokenMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected