-
Notifications
You must be signed in to change notification settings - Fork 10
/
config_test.go
58 lines (55 loc) · 1.42 KB
/
config_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
46
47
48
49
50
51
52
53
54
55
56
57
58
package hazana
import (
"flag"
"testing"
)
func TestLoadConfig(t *testing.T) {
c := ConfigFromFile("config_test.json")
if len(c.Metadata) != 0 {
t.Error("expected empty metadata")
}
if c.RampupTimeSec != 10 {
t.Error("expected RampupTimeSec 10")
}
if c.DoTimeoutSec != 5 {
t.Error("expected timeout 5")
}
}
func TestOverrideLoadedConfig(t *testing.T) {
flag.Set("rps", "31")
flag.Set("attack", "32")
flag.Set("ramp", "33")
flag.Set("max", "34")
flag.Set("o", "here")
flag.Set("verbose", "false")
flag.Set("s", "?")
flag.Set("timeout", "35")
c := ConfigFromFile("config_test.json")
if got, want := c.RPS, 31; got != want {
t.Errorf("got %v want %v", got, want)
}
if got, want := c.AttackTimeSec, 32; got != want {
t.Errorf("got %v want %v", got, want)
}
if got, want := c.RampupTimeSec, 33; got != want {
t.Errorf("got %v want %v", got, want)
}
if got, want := c.MaxAttackers, 34; got != want {
t.Errorf("got %v want %v", got, want)
}
if got, want := c.OutputFilename, "here"; got != want {
t.Errorf("got %v want %v", got, want)
}
if got, want := c.Verbose, false; got != want {
t.Errorf("got %v want %v", got, want)
}
if got, want := c.RampupStrategy, "?"; got != want {
t.Errorf("got %v want %v", got, want)
}
if got, want := c.MaxAttackers, 34; got != want {
t.Errorf("got %v want %v", got, want)
}
if got, want := c.DoTimeoutSec, 35; got != want {
t.Errorf("got %v want %v", got, want)
}
}