-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSummaryBuilder_test.go
More file actions
156 lines (146 loc) · 3.8 KB
/
SummaryBuilder_test.go
File metadata and controls
156 lines (146 loc) · 3.8 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package main
import (
"bytes"
"testing"
"time"
"github.com/guzzlerio/corcel/cmd"
"github.com/guzzlerio/corcel/core"
"github.com/guzzlerio/corcel/serialisation/json"
"github.com/guzzlerio/corcel/serialisation/yaml"
. "github.com/smartystreets/goconvey/convey"
)
func TestSummary_Builders(t *testing.T) {
BeforeTest()
defer AfterTest()
Convey("Summary Builders", t, func() {
var (
builder core.SummaryBuilder
summary core.ExecutionSummary
writer *bytes.Buffer
)
func() {
writer = new(bytes.Buffer)
duration, _ := time.ParseDuration("1.003242751s")
summary = core.ExecutionSummary{
Availability: 100,
Bytes: core.ByteSummary{
Received: core.ByteStat{
Max: 120,
Mean: 120,
Min: 120,
Total: 303480,
},
Sent: core.ByteStat{
Max: 308,
Mean: 136,
Min: 59,
Total: 343864,
},
},
ResponseTime: core.ResponseTimeStat{
Max: 31,
Mean: 6.7081714,
Min: 0,
},
RunningTime: duration,
Throughput: 2544.8113,
TotalAssertionFailures: 0,
TotalAssertions: 0,
TotalErrors: 0,
TotalRequests: 2540,
}
}()
Convey("ConsoleSummaryBuilder", func() {
func() {
builder = cmd.NewConsoleSummaryBuilder(writer)
}()
Convey("writes the expected table to the console", func() {
builder.Write(summary)
So(writer.String(), ShouldContainSubstring, `╔═════════════════════════════════════════════════╗
║ Summary ║
╠═════════════════════════════════════════════════╣
║ Running Time: 1.003242751s ║
║ Throughput: 2545 req/s ║
║ Total Requests: 2540 ║
║ Number of Errors: 0 ║
║ Availability: 100.0000% ║
║ Bytes Sent: 344 kB ║
║ Bytes Received: 304 kB ║
║ Mean Response Time: 6.7082 ms ║
║ Min Response Time: 0.0000 ms ║
║ Max Response Time: 31.0000 ms ║
╚═════════════════════════════════════════════════╝`)
})
})
Convey("JSONSummaryBuilder", func() {
func() {
builder = &json.JSONSummaryBuilder{writer}
}()
Convey("writes the expected table to the console", func() {
builder.Write(summary)
So(writer.String(), json.ShouldMatchJson, `
{
"availability": 100,
"bytes": {
"received": {
"max": 120,
"mean": 120,
"min": 120,
"total": 303480
},
"sent": {
"max": 308,
"mean": 136,
"min": 59,
"total": 343864
}
},
"responseTime": {
"max": 31,
"mean": 6.7081714,
"min": 0
},
"runningTime": 1003242751,
"throughput": 2544.8113,
"totalAssertionFailures": 0,
"totalAssertions": 0,
"totalErrors": 0,
"totalRequests": 2540
}
`)
})
})
Convey("YAMLSummaryBuilder", func() {
func() {
builder = &yaml.YAMLSummaryBuilder{writer}
}()
Convey("writes the expected table to the console", func() {
builder.Write(summary)
So(writer.String(), yaml.ShouldMatchYaml, `
availability: 100
bytes:
received:
max: 120
mean: 120
min: 120
total: 303480
sent:
max: 308
mean: 136
min: 59
total: 343864
responseTime:
max: 31
mean: 6.7081714
min: 0
runningTime: 1003242751
throughput: 2544.8113
totalAssertionFailures: 0
totalAssertions: 0
totalErrors: 0
totalRequests: 2540
`)
})
})
})
}