-
Notifications
You must be signed in to change notification settings - Fork 1
/
action_test.go
48 lines (37 loc) · 1.18 KB
/
action_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
package commander
import (
"errors"
"github.com/WindomZ/testify/assert"
"testing"
)
func testAction(a Action) bool {
if emptyAction(a) {
return false
}
a(newContext(nil, nil))
return true
}
func TestAction_Action(t *testing.T) {
var err error = errors.New("test error")
assert.Equal(t,
testAction(parseAction(func(c Context) _Result { return nil })), true)
assert.Equal(t,
testAction(parseAction(func() _Result { return nil })), true)
assert.Equal(t,
testAction(parseAction(func(c Context) error { return nil })), true)
assert.Equal(t,
testAction(parseAction(func(c Context) error { return err })), true)
assert.Equal(t,
testAction(parseAction(func(c Context) {})), true)
assert.Equal(t,
testAction(parseAction(func() {})), true)
assert.Equal(t,
testAction(parseAction(func() error { return nil })), true)
assert.Equal(t,
testAction(parseAction(func() error { return err })), true)
assert.Equal(t,
testAction(parseAction(func(m map[string]interface{}) error { return nil })), true)
assert.Equal(t,
testAction(parseAction(func(m map[string]interface{}) error { return err })), true)
assert.Equal(t, testAction(parseAction(func() int { return 0 })), false)
}