forked from jacexh/ultron
-
Notifications
You must be signed in to change notification settings - Fork 4
/
handler_test.go
45 lines (39 loc) · 2.19 KB
/
handler_test.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
package ultron
import (
"context"
"errors"
"os"
"testing"
"time"
"github.com/wosai/ultron/v2/pkg/statistics"
)
func TestTerminalTabl(t *testing.T) {
sg := statistics.NewStatisticianGroup()
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 1 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 2 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 3 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 4 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 5 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 6 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 7 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 8 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 9 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 9 * time.Millisecond, Error: errors.New("unknown error")})
report := sg.Report(true)
printReportToConsole(os.Stdout)(context.TODO(), report)
}
func TestPrintJsonReport(t *testing.T) {
sg := statistics.NewStatisticianGroup()
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 1 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 2 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 3 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 4 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 5 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 6 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 7 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 8 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 9 * time.Millisecond})
sg.Record(statistics.AttackResult{Name: "unittest", Duration: 9 * time.Millisecond, Error: errors.New("unknown error")})
report := sg.Report(true)
printJsonReport(os.Stdout)(context.TODO(), report)
}