-
Notifications
You must be signed in to change notification settings - Fork 13
/
test.go
44 lines (38 loc) · 1.29 KB
/
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
package main
import (
"testing"
"github.com/99designs/gqlgen/graphql"
"github.com/coretrix/hitrix/example/entity"
"github.com/coretrix/hitrix/example/rest/middleware"
"github.com/coretrix/hitrix/pkg/test"
"github.com/coretrix/hitrix/service"
"github.com/coretrix/hitrix/service/component/app"
"github.com/coretrix/hitrix/service/registry"
)
func createContextMyApp(
t *testing.T,
projectName string, //nolint //`projectName` always receives `"my-app"`
resolvers graphql.ExecutableSchema, //nolint //`resolvers` always receives `nil`
mockGlobalServices []*service.DefinitionGlobal,
mockRequestServices []*service.DefinitionRequest, //nolint //`resolvers` always receives `nil`
) *test.Environment {
defaultGlobalServices := []*service.DefinitionGlobal{
registry.ServiceProviderConfigDirectory("../example/config"),
registry.ServiceProviderOrmRegistry(entity.Init),
registry.ServiceProviderCrud(nil),
registry.ServiceProviderOrmEngine(),
}
defaultRequestServices := []*service.DefinitionRequest{
registry.ServiceProviderOrmEngineForContext(false),
}
return test.CreateAPIContext(t,
projectName,
resolvers,
middleware.Router,
defaultGlobalServices,
defaultRequestServices,
mockGlobalServices,
mockRequestServices,
&app.RedisPools{Cache: "default", Persistent: "default"},
)
}