forked from ggicci/httpin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirective_test.go
More file actions
45 lines (34 loc) · 1.23 KB
/
directive_test.go
File metadata and controls
45 lines (34 loc) · 1.23 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
package httpin
import (
"testing"
"github.com/stretchr/testify/assert"
)
var noopDirective = DirectiveExecutorFunc(nil)
func TestRegisterDirectiveExecutor(t *testing.T) {
assert.NotPanics(t, func() {
RegisterDirectiveExecutor("noop_TestRegisterDirectiveExecutor", noopDirective)
})
assert.Panics(t, func() {
RegisterDirectiveExecutor("noop_TestRegisterDirectiveExecutor", noopDirective)
}, "should panic on duplicate name")
assert.Panics(t, func() {
RegisterDirectiveExecutor("nil_TestRegisterDirectiveExecutor", nil)
}, "should panic on nil executor")
assert.Panics(t, func() {
RegisterDirectiveExecutor("decoder", noopDirective)
}, "should panic on reserved name")
}
func TestReplaceDirectiveExecutor(t *testing.T) {
assert.NotPanics(t, func() {
ReplaceDirectiveExecutor("noop_TestReplaceDirectiveExecutor", noopDirective)
})
assert.NotPanics(t, func() {
ReplaceDirectiveExecutor("noop_TestReplaceDirectiveExecutor", noopDirective)
}, "should not panic on duplicate name")
assert.Panics(t, func() {
ReplaceDirectiveExecutor("nil_TestReplaceDirectiveExecutor", nil)
}, "should panic on nil executor")
assert.Panics(t, func() {
ReplaceDirectiveExecutor("decoder", noopDirective)
}, "should panic on reserved name")
}