mirror of
https://github.com/vcscsvcscs/GenerationsHeritage.git
synced 2025-08-14 14:59:07 +02:00
implement mocks
This commit is contained in:
59
apps/db-adapter/internal/memgraph/mock/driver.go
Normal file
59
apps/db-adapter/internal/memgraph/mock/driver.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
type DriverWithContext struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
var _ neo4j.DriverWithContext = &DriverWithContext{}
|
||||
|
||||
func (m *DriverWithContext) ExecuteQueryBookmarkManager() neo4j.BookmarkManager {
|
||||
args := m.Called()
|
||||
return args.Get(0).(neo4j.BookmarkManager)
|
||||
}
|
||||
|
||||
func (m *DriverWithContext) Target() url.URL {
|
||||
args := m.Called()
|
||||
return args.Get(0).(url.URL)
|
||||
}
|
||||
|
||||
func (m *DriverWithContext) NewSession(ctx context.Context, config neo4j.SessionConfig) neo4j.SessionWithContext {
|
||||
args := m.Called(ctx, config)
|
||||
return args.Get(0).(neo4j.SessionWithContext)
|
||||
}
|
||||
|
||||
func (m *DriverWithContext) VerifyConnectivity(ctx context.Context) error {
|
||||
args := m.Called(ctx)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *DriverWithContext) VerifyAuthentication(ctx context.Context, auth *neo4j.AuthToken) error {
|
||||
args := m.Called(ctx, auth)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *DriverWithContext) Close(ctx context.Context) error {
|
||||
args := m.Called(ctx)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *DriverWithContext) IsEncrypted() bool {
|
||||
args := m.Called()
|
||||
return args.Bool(0)
|
||||
}
|
||||
|
||||
func (m *DriverWithContext) GetServerInfo(ctx context.Context) (neo4j.ServerInfo, error) {
|
||||
args := m.Called(ctx)
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0).(neo4j.ServerInfo), args.Error(1)
|
||||
}
|
||||
|
||||
return nil, args.Error(1)
|
||||
}
|
115
apps/db-adapter/internal/memgraph/mock/session.go
Normal file
115
apps/db-adapter/internal/memgraph/mock/session.go
Normal file
@@ -0,0 +1,115 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/neo4j/neo4j-go-driver/v5/neo4j"
|
||||
"github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
type SessionWithContext struct {
|
||||
neo4j.SessionWithContext
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
var _ neo4j.SessionWithContext = &SessionWithContext{}
|
||||
|
||||
func (m *SessionWithContext) LastBookmarks() neo4j.Bookmarks {
|
||||
args := m.Called()
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0).(neo4j.Bookmarks)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) lastBookmark() string {
|
||||
args := m.Called()
|
||||
if args.Get(0) != nil {
|
||||
return args.String(0)
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) BeginTransaction(ctx context.Context, configurers ...func(*neo4j.TransactionConfig)) (neo4j.ExplicitTransaction, error) {
|
||||
args := m.Called(ctx, configurers)
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0).(neo4j.ExplicitTransaction), args.Error(1)
|
||||
}
|
||||
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) ExecuteRead(ctx context.Context, work neo4j.ManagedTransactionWork, configurers ...func(*neo4j.TransactionConfig)) (any, error) {
|
||||
args := m.Called(ctx, work, configurers)
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0), args.Error(1)
|
||||
}
|
||||
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) ExecuteWrite(ctx context.Context, work neo4j.ManagedTransactionWork, configurers ...func(*neo4j.TransactionConfig)) (any, error) {
|
||||
args := m.Called(ctx, work, configurers)
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0), args.Error(1)
|
||||
}
|
||||
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) Run(ctx context.Context, cypher string, params map[string]any, configurers ...func(*neo4j.TransactionConfig)) (neo4j.ResultWithContext, error) {
|
||||
args := m.Called(ctx, cypher, params, configurers)
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0).(neo4j.ResultWithContext), args.Error(1)
|
||||
}
|
||||
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) Close(ctx context.Context) error {
|
||||
args := m.Called(ctx)
|
||||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) executeQueryRead(ctx context.Context, work neo4j.ManagedTransactionWork, configurers ...func(*neo4j.TransactionConfig)) (any, error) {
|
||||
args := m.Called(ctx, work, configurers)
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0), args.Error(1)
|
||||
}
|
||||
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) executeQueryWrite(ctx context.Context, work neo4j.ManagedTransactionWork, configurers ...func(*neo4j.TransactionConfig)) (any, error) {
|
||||
args := m.Called(ctx, work, configurers)
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0), args.Error(1)
|
||||
}
|
||||
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) legacy() neo4j.Session {
|
||||
args := m.Called()
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0).(neo4j.Session)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) getServerInfo(ctx context.Context) (neo4j.ServerInfo, error) {
|
||||
args := m.Called(ctx)
|
||||
if args.Get(0) != nil {
|
||||
return args.Get(0).(neo4j.ServerInfo), args.Error(1)
|
||||
}
|
||||
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
func (m *SessionWithContext) verifyAuthentication(ctx context.Context) error {
|
||||
args := m.Called(ctx)
|
||||
return args.Error(0)
|
||||
}
|
Reference in New Issue
Block a user