Skip to content

Commit

Permalink
ARCO-209: replace mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
pawellewandowski98 committed Oct 3, 2024
1 parent 5434a43 commit 128b70f
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion internal/callbacker/callbacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"time"
)

type SendInterface interface {
type SendCallbackInterface interface {
Send(url, token string, callback *Callback) bool
SendBatch(url, token string, callbacks []*Callback) bool
}
Expand Down
32 changes: 16 additions & 16 deletions internal/callbacker/callbacker_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/callbacker/callbacker_mocks.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package callbacker

// from callbacker.go
//go:generate moq -out ./callbacker_mock.go ./ SendInterface
//go:generate moq -out ./callbacker_mock.go ./ SendCallbackInterface
6 changes: 3 additions & 3 deletions internal/callbacker/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package callbacker
The CallbackDispatcher is responsible for routing and dispatching callbacks to appropriate sendManager based on the callback URL.
Key components:
- SendInterface Interface: the CallbackDispatcher decorates this interface, enhancing its functionality by managing the actual dispatch logic
- SendCallbackInterface Interface: the CallbackDispatcher decorates this interface, enhancing its functionality by managing the actual dispatch logic
- sendManager: each sendManager handles specific types of callbacks, determined by the URL
Dispatch Logic: the CallbackDispatcher ensures that callbacks are sent to the correct sendManager, maintaining efficient processing and delivery.
Expand All @@ -23,7 +23,7 @@ import (
)

type CallbackDispatcher struct {
c SendInterface
c SendCallbackInterface
s store.CallbackerStore
l *slog.Logger

Expand All @@ -41,7 +41,7 @@ type CallbackEntry struct {
postponedUntil *time.Time
}

func NewCallbackDispatcher(callbacker SendInterface, store store.CallbackerStore, logger *slog.Logger,
func NewCallbackDispatcher(callbacker SendCallbackInterface, store store.CallbackerStore, logger *slog.Logger,
singleSendPause, batchSendInterval, quarantineBaseDuration, permQuarantineAfterDuration time.Duration) *CallbackDispatcher {

return &CallbackDispatcher{
Expand Down
2 changes: 1 addition & 1 deletion internal/callbacker/dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestCallbackDispatcher(t *testing.T) {
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
// given
cMq := &CallbackerIMock{
cMq := &SendCallbackInterfaceMock{
SendFunc: func(_, _ string, _ *Callback) bool { return true },
}

Expand Down
6 changes: 3 additions & 3 deletions internal/callbacker/send_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The manager operates in various modes:
It processes callbacks from two channels, ensuring either single or batch dispatch, and manages retries based on a quarantine policy.
Key components:
- SendInterface : responsible for sending callbacks
- SendCallbackInterface : responsible for sending callbacks
- quarantine policy: the duration for quarantining a URL are governed by a configurable policy, determining how long the URL remains inactive before retry attempts
Sending logic: callbacks are sent to the designated URL one at a time, ensuring sequential and orderly processing.
Expand All @@ -40,7 +40,7 @@ type sendManager struct {
url string

// dependencies
c SendInterface
c SendCallbackInterface
s store.CallbackerStore
l *slog.Logger
q *quarantinePolicy
Expand Down Expand Up @@ -68,7 +68,7 @@ const (
StoppingMode
)

func runNewSendManager(u string, c SendInterface, s store.CallbackerStore, l *slog.Logger, q *quarantinePolicy,
func runNewSendManager(u string, c SendCallbackInterface, s store.CallbackerStore, l *slog.Logger, q *quarantinePolicy,
singleSendSleep, batchSendInterval time.Duration) *sendManager {

const defaultBatchSendInterval = time.Duration(5 * time.Second)
Expand Down
4 changes: 2 additions & 2 deletions internal/callbacker/send_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestSendManager(t *testing.T) {
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
// given
cMq := &CallbackerIMock{
cMq := &SendCallbackInterfaceMock{
SendFunc: func(_, _ string, _ *Callback) bool { return true },
SendBatchFunc: func(_, _ string, _ []*Callback) bool { return true },
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func TestSendManager_Quarantine(t *testing.T) {

// given
sendOK := true
senderMq := &CallbackerIMock{
senderMq := &SendCallbackInterfaceMock{
SendFunc: func(_, _ string, _ *Callback) bool { return sendOK },
SendBatchFunc: func(_, _ string, _ []*Callback) bool { return sendOK },
}
Expand Down
4 changes: 2 additions & 2 deletions internal/k8s_watcher/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestStartMetamorphWatcher(t *testing.T) {
return 3, nil
},
}
blocktxMock := &btxMocks.BlocktxClientMock{}
blocktxMock := &btxMocks.BlockClientMock{}

iteration := 0
getPodNamesErrTest := tc.getPodNamesErr
Expand Down Expand Up @@ -157,7 +157,7 @@ func TestStartBlocktxWatcher(t *testing.T) {
for _, tc := range tt {
t.Run(tc.name, func(t *testing.T) {
metamorphMock := &mtmMocks.TransactionMaintainerMock{}
blocktxMock := &btxMocks.BlocktxClientMock{
blocktxMock := &btxMocks.BlockClientMock{
DelUnfinishedBlockProcessingFunc: func(_ context.Context, _ string) (int64, error) { return 0, nil },
}

Expand Down

0 comments on commit 128b70f

Please sign in to comment.