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