-
-
Notifications
You must be signed in to change notification settings - Fork 101
/
xml_page_result.go
55 lines (48 loc) · 1.18 KB
/
xml_page_result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
type xmlPageResult struct {
Url string `xml:"name,attr"`
Total int `xml:"tests,attr"`
Failures int `xml:"failures,attr"`
Skipped int `xml:"skipped,attr"`
// spell-checker: disable-next-line
Links []*xmlLinkResult `xml:"testcase"`
}
type xmlLinkResult struct {
Url string `xml:"name,attr"`
// spell-checker: disable-next-line
Source string `xml:"classname,attr"`
Failure *xmlLinkFailure `xml:"failure"`
}
type xmlLinkFailure struct {
Message string `xml:"message,attr"`
}
func newXMLPageResult(pr *pageResult) *xmlPageResult {
ls := make([]*xmlLinkResult, 0, len(pr.SuccessLinkResults)+len(pr.ErrorLinkResults))
for _, r := range pr.SuccessLinkResults {
ls = append(
ls,
&xmlLinkResult{
Url: r.URL,
Source: pr.URL,
},
)
}
for _, r := range pr.ErrorLinkResults {
ls = append(
ls,
&xmlLinkResult{
Url: r.URL,
Source: pr.URL,
Failure: &xmlLinkFailure{Message: r.Error.Error()},
},
)
}
return &xmlPageResult{
Url: pr.URL,
// TODO: Consider adding information skipped links, if that can be tracked.
Skipped: 0,
Total: len(ls),
Failures: len(pr.ErrorLinkResults),
Links: ls,
}
}