-
Notifications
You must be signed in to change notification settings - Fork 477
/
container.go
54 lines (48 loc) · 1.57 KB
/
container.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
51
52
53
54
//
// Copyright (C) 2020 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0
package mocks
import (
"github.com/edgexfoundry/edgex-go/internal/core/data/config"
dataContainer "github.com/edgexfoundry/edgex-go/internal/core/data/container"
v2DataContainer "github.com/edgexfoundry/edgex-go/internal/core/data/v2/bootstrap/container"
"github.com/edgexfoundry/go-mod-bootstrap/bootstrap/container"
bootstrapConfig "github.com/edgexfoundry/go-mod-bootstrap/config"
"github.com/edgexfoundry/go-mod-bootstrap/di"
"github.com/edgexfoundry/go-mod-core-contracts/clients/logger"
"github.com/edgexfoundry/go-mod-messaging/messaging"
msgTypes "github.com/edgexfoundry/go-mod-messaging/pkg/types"
)
// NewMockDIC function returns a mock bootstrap di Container
func NewMockDIC() *di.Container {
msgClient, _ := messaging.NewMessageClient(msgTypes.MessageBusConfig{
PublishHost: msgTypes.HostInfo{
Host: "*",
Protocol: "tcp",
Port: 5563,
},
Type: "zero",
})
return di.NewContainer(di.ServiceConstructorMap{
dataContainer.ConfigurationName: func(get di.Get) interface{} {
return &config.ConfigurationStruct{
Writable: config.WritableInfo{
PersistData: true,
},
Service: bootstrapConfig.ServiceInfo{
MaxResultCount: 20,
},
}
},
container.LoggingClientInterfaceName: func(get di.Get) interface{} {
return logger.NewMockClient()
},
v2DataContainer.MetadataDeviceClientName: func(get di.Get) interface{} {
return NewMockDeviceClient()
},
dataContainer.MessagingClientName: func(get di.Get) interface{} {
return msgClient
},
})
}