From 8175d6ac129e877c6f616a191dd59733fc0127bd Mon Sep 17 00:00:00 2001 From: Carlosokumu Date: Fri, 6 Sep 2024 17:50:33 +0300 Subject: [PATCH] setup db mock --- internal/handlers/ussd/mocks/dbmock.go | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 internal/handlers/ussd/mocks/dbmock.go diff --git a/internal/handlers/ussd/mocks/dbmock.go b/internal/handlers/ussd/mocks/dbmock.go new file mode 100644 index 0000000..71f7eca --- /dev/null +++ b/internal/handlers/ussd/mocks/dbmock.go @@ -0,0 +1,60 @@ +package mocks + +import ( + "context" + + "git.defalsify.org/vise.git/lang" + "git.grassecon.net/urdt/ussd/internal/utils" + "github.com/stretchr/testify/mock" +) + +type MockDb struct { + mock.Mock +} + +func (m *MockDb) SetPrefix(prefix uint8) { + m.Called(utils.DATA_FAMILY_NAME) +} + +func (m *MockDb) Prefix() uint8 { + args := m.Called() + return args.Get(0).(uint8) +} + +func (m *MockDb) Safe() bool { + args := m.Called() + return args.Get(0).(bool) +} + +func (m *MockDb) SetLanguage(language *lang.Language) { + m.Called(language) +} + +func (m *MockDb) SetLock(uint8, bool) error { + args := m.Called() + return args.Error(0) +} + +func (m *MockDb) Connect(ctx context.Context, connectionStr string) error { + args := m.Called(ctx, connectionStr) + return args.Error(0) +} + +func (m *MockDb) SetSession(sessionId string) { + m.Called(sessionId) +} + +func (m *MockDb) Put(ctx context.Context, key, value []byte) error { + args := m.Called(ctx, key, value) + return args.Error(0) +} + +func (m *MockDb) Get(ctx context.Context, key []byte) ([]byte, error) { + args := m.Called(ctx, key) + return nil, args.Error(0) +} + +func (m *MockDb) Close() error { + args := m.Called(nil) + return args.Error(0) +}