(t *testing.T)
| 605 | } |
| 606 | |
| 607 | func TestReadProppatch(t *testing.T) { |
| 608 | ppStr := func(pps []Proppatch) string { |
| 609 | var outer []string |
| 610 | for _, pp := range pps { |
| 611 | var inner []string |
| 612 | for _, p := range pp.Props { |
| 613 | inner = append(inner, fmt.Sprintf("{XMLName: %q, Lang: %q, InnerXML: %q}", |
| 614 | p.XMLName, p.Lang, p.InnerXML)) |
| 615 | } |
| 616 | outer = append(outer, fmt.Sprintf("{Remove: %t, Props: [%s]}", |
| 617 | pp.Remove, strings.Join(inner, ", "))) |
| 618 | } |
| 619 | return "[" + strings.Join(outer, ", ") + "]" |
| 620 | } |
| 621 | |
| 622 | testCases := []struct { |
| 623 | desc string |
| 624 | input string |
| 625 | wantPP []Proppatch |
| 626 | wantStatus int |
| 627 | }{{ |
| 628 | desc: "proppatch: section 9.2 (with simple property value)", |
| 629 | input: `` + |
| 630 | `<?xml version="1.0" encoding="utf-8" ?>` + |
| 631 | `<D:propertyupdate xmlns:D="DAV:"` + |
| 632 | ` xmlns:Z="http://ns.example.com/z/">` + |
| 633 | ` <D:set>` + |
| 634 | ` <D:prop><Z:Authors>somevalue</Z:Authors></D:prop>` + |
| 635 | ` </D:set>` + |
| 636 | ` <D:remove>` + |
| 637 | ` <D:prop><Z:Copyright-Owner/></D:prop>` + |
| 638 | ` </D:remove>` + |
| 639 | `</D:propertyupdate>`, |
| 640 | wantPP: []Proppatch{{ |
| 641 | Props: []Property{{ |
| 642 | xml.Name{Space: "http://ns.example.com/z/", Local: "Authors"}, |
| 643 | "", |
| 644 | []byte(`somevalue`), |
| 645 | }}, |
| 646 | }, { |
| 647 | Remove: true, |
| 648 | Props: []Property{{ |
| 649 | xml.Name{Space: "http://ns.example.com/z/", Local: "Copyright-Owner"}, |
| 650 | "", |
| 651 | nil, |
| 652 | }}, |
| 653 | }}, |
| 654 | }, { |
| 655 | desc: "proppatch: lang attribute on prop", |
| 656 | input: `` + |
| 657 | `<?xml version="1.0" encoding="utf-8" ?>` + |
| 658 | `<D:propertyupdate xmlns:D="DAV:">` + |
| 659 | ` <D:set>` + |
| 660 | ` <D:prop xml:lang="en">` + |
| 661 | ` <foo xmlns="http://example.com/ns"/>` + |
| 662 | ` </D:prop>` + |
| 663 | ` </D:set>` + |
| 664 | `</D:propertyupdate>`, |
nothing calls this directly
no test coverage detected