forked from go-bdd/gobdd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
steps_context_test.go
35 lines (29 loc) · 993 Bytes
/
steps_context_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
package gobdd_test
import (
"testing"
gobdd "github.com/go-bdd/gobdd"
"github.com/go-bdd/gobdd/context"
)
func TestValidateStepFunc_Context(t *testing.T) {
testCases := map[string]interface{}{
"function with invalid first argument": func(int, context.Context) {},
}
for name, testCase := range testCases {
t.Run(name, func(t *testing.T) {
if err := gobdd.ValidateStepFunc(testCase); err == nil {
t.Errorf("the test should fail for the function")
}
})
}
}
func TestValidateStepFunc_ValidFunction_Context(t *testing.T) {
if err := gobdd.ValidateStepFunc(func(gobdd.StepTest, context.Context) {}); err != nil {
t.Errorf("the test should NOT fail for the function: %s", err)
}
}
func TestValidateStepFunc_ReturnContext_Context(t *testing.T) {
err := gobdd.ValidateStepFunc(func(gobdd.StepTest, context.Context) context.Context { return context.Context{} })
if err != nil {
t.Errorf("step function returning a context should NOT fail validation: %s", err)
}
}