/
testsuite_desc.go
96 lines (71 loc) · 1.75 KB
/
testsuite_desc.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package teststruct
type TSDescribe struct {
// Errors int `json:"errors"`
Status string `json:"status"`
// Failures int `json:"failures"`
Name string `json:"name"`
ID uint64 `json:"id"`
// TestCaseCount int `json:"testcasescount"`
// TestStepsCount int `json:"teststepscount"`
TestCases []TCDescribe `json:"testcases"`
}
func (ts *TestSuite) ToJSON() TSDescribe {
ts.Mutex.RLock()
var TSDesc TSDescribe
TSDesc.TestCases = make([]TCDescribe, 0, len(ts.TestCases))
for _, tc := range ts.TestCases {
// TSDesc.TestStepsCount += tc.countTestStep()
tsD := tc.ToJSON()
TSDesc.TestCases = append(TSDesc.TestCases, tsD)
}
TSDesc.Name = ts.Name
TSDesc.ID = ts.ID
// TSDesc.TestCaseCount = len(ts.TestCases)
// TSDesc.Failures = ts.Failures()
TSDesc.Status = ts.Status.String()
ts.Mutex.RUnlock()
return TSDesc
}
type TSHeader struct {
ID uint64 `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
}
func (ts *TestSuite) ToHeader() TSHeader {
ts.Mutex.RLock()
hts := TSHeader{
Name: ts.Name,
ID: ts.ID,
Status: ts.Status.String(),
}
ts.Mutex.RUnlock()
return hts
}
type TSAlertShort struct {
TSHeader
TestCases map[uint64]TCAlertShort `json:"testcases"`
}
func (ts *TestSuite) ToAlertShortTSRec() TSAlertShort {
htc := ts.ToHeader()
AsTC := TSAlertShort{
TSHeader: htc,
TestCases: nil,
}
return AsTC
}
func (ts *TestSuite) ToAlertShortTS() TSAlertShort {
htc := ts.ToHeader()
TCAlerts := make(map[uint64]TCAlertShort, 0)
AsTC := TSAlertShort{
TSHeader: htc,
TestCases: TCAlerts,
}
/*
ts.Mutex.RLock()
for _, tc := range ts.TestCases {
TCAlerts = append(TCAlerts, tc.ToAlertShortTC())
}
ts.Mutex.RUnlock()
*/
return AsTC
}