2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 import "github.com/stretchr/testify/mock"
21 type MockSdlInstance struct {
25 func (m *MockSdlInstance) SubscribeChannel(cb func(string, ...string), channels ...string) error {
26 a := m.Called(cb, channels)
30 func (m *MockSdlInstance) UnsubscribeChannel(channels ...string) error {
31 a := m.Called(channels)
35 func (m *MockSdlInstance) SetAndPublish(channelsAndEvents []string, pairs ...interface{}) error {
36 a := m.Called(channelsAndEvents, pairs)
40 func (m *MockSdlInstance) SetIfAndPublish(channelsAndEvents []string, key string, oldData, newData interface{}) (bool, error) {
41 a := m.Called(channelsAndEvents, key, oldData, newData)
42 return a.Bool(0), a.Error(1)
45 func (m *MockSdlInstance) SetIfNotExistsAndPublish(channelsAndEvents []string, key string, data interface{}) (bool, error) {
46 a := m.Called(channelsAndEvents, key, data)
47 return a.Bool(0), a.Error(1)
50 func (m *MockSdlInstance) RemoveAndPublish(channelsAndEvents []string, keys []string) error {
51 a := m.Called(channelsAndEvents, keys)
55 func (m *MockSdlInstance) RemoveIfAndPublish(channelsAndEvents []string, key string, data interface{}) (bool, error) {
56 a := m.Called(channelsAndEvents, key, data)
57 return a.Bool(0), a.Error(1)
60 func (m *MockSdlInstance) RemoveAllAndPublish(channelsAndEvents []string) error {
61 a := m.Called(channelsAndEvents)
65 func (m *MockSdlInstance) Set(pairs ...interface{}) error {
70 func (m *MockSdlInstance) Get(keys []string) (map[string]interface{}, error) {
72 return a.Get(0).(map[string]interface{}), a.Error(1)
75 func (m *MockSdlInstance) GetAll() ([]string, error) {
77 return a.Get(0).([]string), a.Error(1)
80 func (m *MockSdlInstance) Close() error {
85 func (m *MockSdlInstance) Remove(keys []string) error {
90 func (m *MockSdlInstance) RemoveAll() error {
95 func (m *MockSdlInstance) SetIf(key string, oldData, newData interface{}) (bool, error) {
96 a := m.Called(key, oldData, newData)
97 return a.Bool(0), a.Error(1)
100 func (m *MockSdlInstance) SetIfNotExists(key string, data interface{}) (bool, error) {
101 a := m.Called(key, data)
102 return a.Bool(0), a.Error(1)
104 func (m *MockSdlInstance) RemoveIf(key string, data interface{}) (bool, error) {
105 a := m.Called(key, data)
106 return a.Bool(0), a.Error(1)
109 func (m *MockSdlInstance) AddMember(group string, member ...interface{}) error {
110 a := m.Called(group, member)
114 func (m *MockSdlInstance) RemoveMember(group string, member ...interface{}) error {
115 a := m.Called(group, member)
118 func (m *MockSdlInstance) RemoveGroup(group string) error {
122 func (m *MockSdlInstance) GetMembers(group string) ([]string, error) {
124 return a.Get(0).([]string), a.Error(1)
126 func (m *MockSdlInstance) IsMember(group string, member interface{}) (bool, error) {
127 a := m.Called(group, member)
128 return a.Bool(0), a.Error(1)
130 func (m *MockSdlInstance) GroupSize(group string) (int64, error) {
131 a := m.Called(group, )
132 return int64(a.Int(0)), a.Error(1)