(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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{ |
nothing calls this directly
no test coverage detected