-
Notifications
You must be signed in to change notification settings - Fork 13
/
test.go
50 lines (44 loc) · 1.48 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
46
47
48
49
50
package main
import (
"testing"
"github.com/99designs/gqlgen/graphql"
"github.com/coretrix/hitrix/example/entity/initialize"
"github.com/coretrix/hitrix/example/redis"
"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(initialize.Init),
registry.ServiceProviderCrud(nil),
registry.ServiceProviderOrmEngine(redis.SearchPool),
}
defaultRequestServices := []*service.DefinitionRequest{
registry.ServiceProviderOrmEngineForContext(false, redis.SearchPool),
}
return test.CreateAPIContext(t,
projectName,
resolvers,
middleware.Router,
defaultGlobalServices,
defaultRequestServices,
mockGlobalServices,
mockRequestServices,
&app.RedisPools{
Cache: redis.DefaultPool,
Persistent: redis.DefaultPool,
Stream: redis.StreamsPool,
Search: redis.SearchPool,
},
)
}