-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeedrail_test.go
More file actions
35 lines (30 loc) · 905 Bytes
/
speedrail_test.go
File metadata and controls
35 lines (30 loc) · 905 Bytes
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 speedrail_test
import (
"context"
"github.com/Kansuler/speedrail"
"github.com/stretchr/testify/suite"
"net/http"
"testing"
)
type SpeedrailTestSuite struct {
suite.Suite
}
func (suite *SpeedrailTestSuite) TestPlanExecute() {
plan := speedrail.Plan[any, any]()
_, _, err := plan.Execute(context.Background(), nil, nil)
suite.Error(err)
suite.Equal(err.StatusCode(), http.StatusInternalServerError)
suite.ErrorIs(err, speedrail.ErrNoStrategy)
plan = speedrail.Plan[any, any](
func(ctx context.Context, container any, model any) (context.Context, any, speedrail.Error) {
return nil, nil, nil
},
)
_, _, err = plan.Execute(context.Background(), nil, nil)
suite.Error(err)
suite.Equal(err.StatusCode(), http.StatusInternalServerError)
suite.ErrorIs(err, speedrail.ErrNoContextReturned)
}
func TestSpeedrailTestSuite(t *testing.T) {
suite.Run(t, new(SpeedrailTestSuite))
}