forked from grassrootseconomics/visedriver
		
	remove deprecated code
This commit is contained in:
		
							parent
							
								
									c0a3ad7e2b
								
							
						
					
					
						commit
						ad48890a9f
					
				| @ -3,28 +3,16 @@ package mocks | ||||
| import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"git.defalsify.org/vise.git/lang" | ||||
| 	"git.defalsify.org/vise.git/db" | ||||
| 	"git.grassecon.net/urdt/ussd/internal/utils" | ||||
| 	"github.com/stretchr/testify/mock" | ||||
| ) | ||||
| 
 | ||||
| type MockUserDataStore struct { | ||||
| 	db.Db | ||||
| 	mock.Mock | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) SetPrefix(prefix uint8) { | ||||
| 	m.Called(prefix) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) SetSession(sessionId string) { | ||||
| 	m.Called(sessionId) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) Get(ctx context.Context, key []byte) ([]byte, error) { | ||||
| 	args := m.Called(ctx, key) | ||||
| 	return args.Get(0).([]byte), args.Error(1) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) ReadEntry(ctx context.Context, sessionId string, typ utils.DataTyp) ([]byte, error) { | ||||
| 	args := m.Called(ctx, sessionId, typ) | ||||
| 	return args.Get(0).([]byte), args.Error(1) | ||||
| @ -34,36 +22,3 @@ func (m *MockUserDataStore) WriteEntry(ctx context.Context, sessionId string, ty | ||||
| 	args := m.Called(ctx, sessionId, typ, value) | ||||
| 	return args.Error(0) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) Prefix() uint8 { | ||||
| 	args := m.Called() | ||||
| 	return args.Get(0).(uint8) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) Safe() bool { | ||||
| 	args := m.Called() | ||||
| 	return args.Get(0).(bool) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) SetLanguage(language *lang.Language) { | ||||
| 	m.Called(language) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) SetLock(uint8, bool) error { | ||||
| 	args := m.Called() | ||||
| 	return args.Error(0) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) Connect(ctx context.Context, connectionStr string) error { | ||||
| 	args := m.Called(ctx, connectionStr) | ||||
| 	return args.Error(0) | ||||
| } | ||||
| 
 | ||||
| func (m *MockUserDataStore) Put(ctx context.Context, key, value []byte) error { | ||||
| 	args := m.Called(ctx, key, value) | ||||
| 	return args.Error(0) | ||||
| } | ||||
| func (m *MockUserDataStore) Close() error { | ||||
| 	args := m.Called(nil) | ||||
| 	return args.Error(0) | ||||
| } | ||||
|  | ||||
| @ -4,78 +4,29 @@ import ( | ||||
| 	"context" | ||||
| 
 | ||||
| 	"git.defalsify.org/vise.git/db" | ||||
| 	"git.defalsify.org/vise.git/lang" | ||||
| ) | ||||
| 
 | ||||
| type DataStore interface { | ||||
| 	SetPrefix(prefix uint8) | ||||
| 	SetSession(sessionId string) | ||||
| 	Get(ctx context.Context, key []byte) ([]byte, error) | ||||
| 	db.Db | ||||
| 	ReadEntry(ctx context.Context, sessionId string, typ DataTyp) ([]byte, error) | ||||
| 	WriteEntry(ctx context.Context, sessionId string, typ DataTyp, value []byte) error | ||||
| 	Connect(ctx context.Context, connStr string) error | ||||
| 	SetLanguage(*lang.Language) | ||||
| 	Close() error | ||||
| 	Prefix() uint8 | ||||
| 	Put(ctx context.Context, key []byte, val []byte) error | ||||
| 	Safe() bool | ||||
| 	SetLock(typ uint8, locked bool) error | ||||
| } | ||||
| 
 | ||||
| type UserDataStore struct { | ||||
| 	Store db.Db | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) SetPrefix(prefix uint8) { | ||||
| 	store.Store.SetPrefix(prefix) | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) SetLanguage(lang *lang.Language) { | ||||
| 	store.Store.SetLanguage(lang) | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) SetLock(typ uint8, locked bool) error { | ||||
| 	return store.Store.SetLock(typ, locked) | ||||
| } | ||||
| func (store UserDataStore) Safe() bool { | ||||
| 	return store.Store.Safe() | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) Put(ctx context.Context, key []byte, val []byte) error { | ||||
| 	return store.Store.Put(ctx, key, val) | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) Connect(ctx context.Context, connectionStr string) error { | ||||
| 	return store.Store.Connect(ctx, connectionStr) | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) Close() error { | ||||
| 	return store.Store.Close() | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) Prefix() uint8 { | ||||
| 	return store.Store.Prefix() | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) SetSession(sessionId string) { | ||||
| 	store.Store.SetSession(sessionId) | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) Get(ctx context.Context, key []byte) ([]byte, error) { | ||||
| 	return store.Store.Get(ctx, key) | ||||
| 	db.Db | ||||
| } | ||||
| 
 | ||||
| // ReadEntry retrieves an entry from the store based on the provided parameters.
 | ||||
| func (store UserDataStore) ReadEntry(ctx context.Context, sessionId string, typ DataTyp) ([]byte, error) { | ||||
| 	store.Store.SetPrefix(db.DATATYPE_USERDATA) | ||||
| 	store.Store.SetSession(sessionId) | ||||
| func (store *UserDataStore) ReadEntry(ctx context.Context, sessionId string, typ DataTyp) ([]byte, error) { | ||||
| 	store.SetPrefix(db.DATATYPE_USERDATA) | ||||
| 	store.SetSession(sessionId) | ||||
| 	k := PackKey(typ, []byte(sessionId)) | ||||
| 	return store.Get(ctx, k) | ||||
| } | ||||
| 
 | ||||
| func (store UserDataStore) WriteEntry(ctx context.Context, sessionId string, typ DataTyp, value []byte) error { | ||||
| 	store.Store.SetPrefix(db.DATATYPE_USERDATA) | ||||
| 	store.Store.SetSession(sessionId) | ||||
| func (store *UserDataStore) WriteEntry(ctx context.Context, sessionId string, typ DataTyp, value []byte) error { | ||||
| 	store.SetPrefix(db.DATATYPE_USERDATA) | ||||
| 	store.SetSession(sessionId) | ||||
| 	k := PackKey(typ, []byte(sessionId)) | ||||
| 	return store.Store.Put(ctx, k, value) | ||||
| 	return store.Put(ctx, k, value) | ||||
| } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user