This repository was archived by the owner on Jul 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.go
More file actions
64 lines (55 loc) · 1.28 KB
/
analytics.go
File metadata and controls
64 lines (55 loc) · 1.28 KB
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
56
57
58
59
60
61
62
63
64
package parse
type AnalyticsTestSet struct {
Name string
Time FloatNumber
Total int
Failures int
Errors int
Skipped int
}
type AnalyticsTest struct {
Name string
Time FloatNumber
Failure string
Error string
Status string
NumericStatus int
TestSet AnalyticsTestSet
}
func ToAnalyticsTests(junit []byte) ([]AnalyticsTest, error) {
testSet, err := ToTestSet(junit)
if err != nil {
return nil, err
}
var ret []AnalyticsTest
analyticsTestSet := getAnalyticsTestSet(testSet)
for _, currTest := range testSet.Tests {
ret = append(ret,
AnalyticsTest{
Name: currTest.Name,
Status: currTest.Status,
Time: FloatNumber(currTest.Time),
Failure: currTest.Failure,
Error: currTest.Error,
NumericStatus: toNumericStatus(currTest.Status),
TestSet: analyticsTestSet})
}
return ret, nil
}
func toNumericStatus(status string) int {
ret := 0
if status != Passed {
ret = 1
}
return ret
}
func getAnalyticsTestSet(testSet *TestSet) AnalyticsTestSet {
return AnalyticsTestSet{
Name: testSet.Name,
Time: FloatNumber(testSet.Time),
Total: testSet.Total,
Failures: testSet.Failures,
Errors: testSet.Errors,
Skipped: testSet.Skipped,
}
}