mocks

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockFactory

type MockFactory struct {
	mock.Mock
}

MockFactory는 Factory 인터페이스의 Mock 구현체입니다. "github.com/stretchr/testify/mock" 패키지를 사용하여 동작을 정의하고 검증할 수 있습니다.

func NewMockFactory

func NewMockFactory(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockFactory

NewMockFactory는 새로운 MockFactory 인스턴스를 생성하고, 테스트 객체(t)와 연결합니다. 테스트가 종료될 때 모든 Mock 기대치(Expectations)가 충족되었는지 자동으로 검증됩니다.

func (*MockFactory) CreateAll

func (m *MockFactory) CreateAll(cfg *config.AppConfig, executor contract.TaskExecutor) ([]notifier.Notifier, error)

CreateAll은 설정된 Notifier 목록을 반환합니다.

func (*MockFactory) ExpectCreateAllFailure

func (m *MockFactory) ExpectCreateAllFailure(err error) *mock.Call

ExpectCreateAllFailure는 CreateAll 호출 시 에러를 반환하도록 설정합니다.

func (*MockFactory) ExpectCreateAllSuccess

func (m *MockFactory) ExpectCreateAllSuccess(notifiers []notifier.Notifier) *mock.Call

ExpectCreateAllSuccess는 CreateAll 호출 시 지정된 Notifier 목록을 반환하도록 설정합니다.

func (*MockFactory) ExpectRegister

func (m *MockFactory) ExpectRegister() *mock.Call

ExpectRegister는 Register 호출을 기대하고, 아무런 동작도 하지 않도록 설정합니다.

func (*MockFactory) OnCreateAll

func (m *MockFactory) OnCreateAll(cfg interface{}, executor interface{}) *mock.Call

OnCreateAll은 CreateAll 메서드 호출에 대한 기대치를 설정하는 헬퍼입니다. 반환된 *mock.Call을 통해 Return, Run, Once 등을 체이닝할 수 있습니다.

func (*MockFactory) OnRegister

func (m *MockFactory) OnRegister(creator interface{}) *mock.Call

OnRegister는 Register 메서드 호출에 대한 기대치를 설정하는 헬퍼입니다.

func (*MockFactory) Register

func (m *MockFactory) Register(creator notifier.Creator)

Register는 새로운 Creator를 등록합니다.

func (*MockFactory) WithCreateAll

func (m *MockFactory) WithCreateAll(notifiers []notifier.Notifier, err error) *MockFactory

WithCreateAll configures the mock to return specific notifiers for CreateAll calls. Deprecated: Use OnCreateAll or ExpectCreateAllSuccess instead.

func (*MockFactory) WithRegister

func (m *MockFactory) WithRegister() *MockFactory

WithRegister configures the mock to expect Register calls. Deprecated: Use OnRegister or ExpectRegister instead.

type MockNotificationSender

type MockNotificationSender struct {
	mock.Mock
}

MockNotificationSender 테스트용 NotificationSender 및 HealthChecker 구현체입니다. "github.com/stretchr/testify/mock" 패키지를 사용하여 동작을 정의하고 검증할 수 있습니다.

func NewMockNotificationSender

func NewMockNotificationSender(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockNotificationSender

NewMockNotificationSender 새로운 MockNotificationSender 인스턴스를 생성합니다.

주요 기능:

  • t.Cleanup을 사용하여 테스트 종료 시 AssertExpectations 자동 호출
  • SupportsHTML 메서드에 대한 기본 허용적 설정을 적용합니다.

func (*MockNotificationSender) ExpectHealthy

func (m *MockNotificationSender) ExpectHealthy() *mock.Call

ExpectHealthy Health 호출 시 정상(nil error)을 가정합니다.

func (*MockNotificationSender) ExpectNotifyFailure

func (m *MockNotificationSender) ExpectNotifyFailure(err error) *mock.Call

ExpectNotifyFailure Notify 호출 실패를 가정합니다.

func (*MockNotificationSender) ExpectNotifySuccess

func (m *MockNotificationSender) ExpectNotifySuccess() *mock.Call

ExpectNotifySuccess Notify 호출 성공을 가정합니다.

func (*MockNotificationSender) ExpectUnhealthy

func (m *MockNotificationSender) ExpectUnhealthy(err error) *mock.Call

ExpectUnhealthy Health 호출 시 에러를 가정합니다.

func (*MockNotificationSender) Health

func (m *MockNotificationSender) Health() error

Health 서비스 상태를 확인합니다.

func (*MockNotificationSender) Notify

func (m *MockNotificationSender) Notify(ctx context.Context, notification contract.Notification) error

Notify 메타데이터와 함께 알림을 전송합니다.

func (*MockNotificationSender) OnHealth

func (m *MockNotificationSender) OnHealth() *mock.Call

OnHealth Health 메서드 호출에 대한 기대치를 설정합니다.

func (*MockNotificationSender) OnNotify

func (m *MockNotificationSender) OnNotify(ctx interface{}, notification interface{}) *mock.Call

OnNotify Notify 메서드 호출에 대한 기대치를 설정합니다.

func (*MockNotificationSender) SupportsHTML

func (m *MockNotificationSender) SupportsHTML(notifierID contract.NotifierID) bool

SupportsHTML HTML 지원 여부를 반환합니다.

func (*MockNotificationSender) WithHealthy

WithHealthy configures the mock to return nil for Health calls (healthy state). Deprecated: Use ExpectHealthy instead.

func (*MockNotificationSender) WithNotify

WithNotify configures the mock to return a specific error for Notify calls. Deprecated: Use OnNotify or ExpectNotifySuccess instead.

func (*MockNotificationSender) WithUnhealthy

func (m *MockNotificationSender) WithUnhealthy(err error) *MockNotificationSender

WithUnhealthy configures the mock to return an error for Health calls (unhealthy state). Deprecated: Use ExpectUnhealthy instead.

type MockNotifier

type MockNotifier struct {
	mock.Mock
}

MockNotifier는 Notifier 인터페이스의 Mock 구현체입니다. "github.com/stretchr/testify/mock" 패키지를 사용하여 동작을 정의하고 검증할 수 있습니다.

func NewMockNotifier

func NewMockNotifier(t interface {
	mock.TestingT
	Cleanup(func())
}, id contract.NotifierID) *MockNotifier

NewMockNotifier는 새로운 MockNotifier 인스턴스를 생성합니다.

주요 기능:

  • t.Cleanup을 사용하여 테스트 종료 시 AssertExpectations 자동 호출
  • ID, Run, Done 등 기본 메서드에 대한 허용적(Permissive) Mock 설정 자동 적용 (일일이 설정하지 않아도 테스트가 실패하지 않도록)

func (*MockNotifier) Close

func (m *MockNotifier) Close()

Close closes the notifier.

func (*MockNotifier) Done

func (m *MockNotifier) Done() <-chan struct{}

Done returns a channel that is closed when the notifier is done.

func (*MockNotifier) ExpectClose

func (m *MockNotifier) ExpectClose() *mock.Call

ExpectClose Close 호출을 가정합니다.

func (*MockNotifier) ExpectSendFailure

func (m *MockNotifier) ExpectSendFailure(err error) *mock.Call

ExpectSendFailure Send 호출 실패를 가정합니다.

func (*MockNotifier) ExpectSendSuccess

func (m *MockNotifier) ExpectSendSuccess() *mock.Call

ExpectSendSuccess Send 호출 성공을 가정합니다.

func (*MockNotifier) ExpectTrySendFailure

func (m *MockNotifier) ExpectTrySendFailure(err error) *mock.Call

ExpectTrySendFailure TrySend 호출 실패를 가정합니다.

func (*MockNotifier) ExpectTrySendSuccess

func (m *MockNotifier) ExpectTrySendSuccess() *mock.Call

ExpectTrySendSuccess TrySend 호출 성공을 가정합니다.

func (*MockNotifier) ID

ID returns the notifier's ID.

func (*MockNotifier) OnClose

func (m *MockNotifier) OnClose() *mock.Call

OnClose Close 메서드 호출에 대한 기대치를 설정합니다.

func (*MockNotifier) OnSend

func (m *MockNotifier) OnSend(ctx interface{}, notification interface{}) *mock.Call

OnSend Send 메서드 호출에 대한 기대치를 설정합니다.

func (*MockNotifier) OnTrySend

func (m *MockNotifier) OnTrySend(ctx interface{}, notification interface{}) *mock.Call

OnTrySend TrySend 메서드 호출에 대한 기대치를 설정합니다.

func (*MockNotifier) Run

func (m *MockNotifier) Run(ctx context.Context)

Run runs the notifier.

func (*MockNotifier) Send

func (m *MockNotifier) Send(ctx context.Context, notification contract.Notification) error

Send sends a notification.

func (*MockNotifier) SupportsHTML

func (m *MockNotifier) SupportsHTML() bool

SupportsHTML returns whether the notifier supports HTML.

func (*MockNotifier) TrySend

func (m *MockNotifier) TrySend(ctx context.Context, notification contract.Notification) error

TrySend sends a notification without blocking.

func (*MockNotifier) WithSend

func (m *MockNotifier) WithSend(err error) *MockNotifier

WithSend configures the mock to return a specific error for Send calls. Deprecated: Use OnSend or ExpectSendSuccess instead.

func (*MockNotifier) WithSupportsHTML

func (m *MockNotifier) WithSupportsHTML(supported bool) *MockNotifier

WithSupportsHTML configures the mock to return a specific boolean for SupportsHTML calls. Deprecated: Use On("SupportsHTML").Return(supported) instead.

Jump to

Keyboard shortcuts

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