mocks

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockCache

type MockCache struct {
	// contains filtered or unexported fields
}

MockCache is an in-memory mock implementation of the Cache interface Used for testing without requiring a real Redis instance

func NewMockCache

func NewMockCache() *MockCache

NewMockCache creates a new mock cache instance

func (*MockCache) Clear

func (m *MockCache) Clear()

Clear resets the mock cache (useful for tests)

func (*MockCache) Close

func (m *MockCache) Close() error

Close is a no-op for mock

func (*MockCache) Decr

func (m *MockCache) Decr(ctx context.Context, key string) (int64, error)

Decr decrements a key's value

func (*MockCache) Del

func (m *MockCache) Del(ctx context.Context, keys ...string) error

Del deletes keys from the mock cache

func (*MockCache) Exists

func (m *MockCache) Exists(ctx context.Context, keys ...string) (int64, error)

Exists checks if keys exist in the mock cache

func (*MockCache) Expire

func (m *MockCache) Expire(ctx context.Context, key string, expiration time.Duration) error

Expire sets an expiration on a key (no-op in mock)

func (*MockCache) Get

func (m *MockCache) Get(ctx context.Context, key string) (string, error)

Get retrieves a value from the mock cache

func (*MockCache) Health

func (m *MockCache) Health(ctx context.Context) error

Health always returns nil for mock

func (*MockCache) Incr

func (m *MockCache) Incr(ctx context.Context, key string) (int64, error)

Incr increments a key's value

func (*MockCache) SAdd

func (m *MockCache) SAdd(ctx context.Context, key string, members ...interface{}) error

SAdd adds members to a set

func (*MockCache) SIsMember

func (m *MockCache) SIsMember(ctx context.Context, key string, member interface{}) (bool, error)

SIsMember checks if a member exists in a set

func (*MockCache) SMembers

func (m *MockCache) SMembers(ctx context.Context, key string) ([]string, error)

SMembers returns all members of a set

func (*MockCache) SRem

func (m *MockCache) SRem(ctx context.Context, key string, members ...interface{}) error

SRem removes members from a set

func (*MockCache) Set

func (m *MockCache) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error

Set stores a value in the mock cache

func (*MockCache) SetNX

func (m *MockCache) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)

SetNX sets a key only if it doesn't exist (for distributed locking)

type MockGitLabClient

type MockGitLabClient struct {
	GetCodeownersFunc     func(projectID int, ref string) (string, error)
	GetUserStatusFunc     func(userID int) (*gitlab.UserStatus, error)
	PostCommentFunc       func(projectID, mrIID int, comment string) (int, error)
	UpdateCommentFunc     func(projectID, mrIID, noteID int, comment string) error
	GetMRChangedFilesFunc func(projectID, mrIID int) ([]string, error)
}

MockGitLabClient is a simple mock for GitLab client

func (*MockGitLabClient) GetCodeowners

func (m *MockGitLabClient) GetCodeowners(projectID int, ref string) (string, error)

func (*MockGitLabClient) GetMRChangedFiles

func (m *MockGitLabClient) GetMRChangedFiles(projectID, mrIID int) ([]string, error)

func (*MockGitLabClient) GetUserStatus

func (m *MockGitLabClient) GetUserStatus(userID int) (*gitlab.UserStatus, error)

func (*MockGitLabClient) PostComment

func (m *MockGitLabClient) PostComment(projectID, mrIID int, comment string) (int, error)

func (*MockGitLabClient) UpdateComment

func (m *MockGitLabClient) UpdateComment(projectID, mrIID, noteID int, comment string) error

type MockUserRepository

type MockUserRepository struct {
	GetByUsernameFunc func(username string) (*models.User, error)
	GetByGitLabIDFunc func(gitlabID int) (*models.User, error)
	GetByTeamFunc     func(team string) ([]models.User, error)
	GetAllFunc        func() ([]models.User, error)
}

MockUserRepository is a simple mock for user repository

func (*MockUserRepository) GetAll

func (m *MockUserRepository) GetAll() ([]models.User, error)

func (*MockUserRepository) GetByGitLabID

func (m *MockUserRepository) GetByGitLabID(gitlabID int) (*models.User, error)

func (*MockUserRepository) GetByTeam

func (m *MockUserRepository) GetByTeam(team string) ([]models.User, error)

func (*MockUserRepository) GetByUsername

func (m *MockUserRepository) GetByUsername(username string) (*models.User, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL