* middleware/erratic: allow TC bit to be set

Add `truncate` as an option.

Fixes #593
This commit is contained in:
Miek Gieben 2017-04-16 07:49:13 +01:00 committed by GitHub
parent a83d97a5c4
commit 73397e4667
5 changed files with 110 additions and 21 deletions

View file

@ -33,22 +33,28 @@ func TestParseErratic(t *testing.T) {
shouldErr bool
drop uint64
delay uint64
truncate uint64
}{
// oks
{`erratic`, false, 2, 0},
{`erratic`, false, 2, 0, 0},
{`erratic {
drop 2
delay 3 1ms
}`, false, 2, 3},
}`, false, 2, 3, 0},
{`erratic {
truncate 2
delay 3 1ms
}`, false, 0, 3, 2},
// fails
{`erratic {
drop -1
}`, true, 0, 0},
}`, true, 0, 0, 0},
{`erraric {
drop 3
delay 3 bla
}`, true, 0, 0},
}`, true, 0, 0, 0},
}
for i, test := range tests {
c := caddy.NewTestController("dns", test.input)
@ -68,9 +74,11 @@ func TestParseErratic(t *testing.T) {
if test.delay != e.delay {
t.Errorf("Test %v: Expected delay %d but found: %d", i, test.delay, e.delay)
}
if test.drop != e.drop {
t.Errorf("Test %v: Expected drop %d but found: %d", i, test.drop, e.drop)
}
if test.truncate != e.truncate {
t.Errorf("Test %v: Expected truncate %d but found: %d", i, test.truncate, e.truncate)
}
}
}