Skip to content

Commit

Permalink
Modify SignalInterface to use mockery-v2
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Apolinario <[email protected]>
  • Loading branch information
eapolinario committed May 23, 2024
1 parent ac4cbae commit 8b12e0a
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 43 deletions.
2 changes: 1 addition & 1 deletion flyteadmin/pkg/manager/interfaces/signal.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin"
)

//go:generate mockery -name=SignalInterface -output=../mocks -case=underscore
//go:generate mockery-v2 --name=SignalInterface --output=../mocks --case=underscore --with-expecter

// Interface for managing Flyte Signals
type SignalInterface interface {
Expand Down
148 changes: 112 additions & 36 deletions flyteadmin/pkg/manager/mocks/signal_interface.go

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

12 changes: 6 additions & 6 deletions flyteadmin/pkg/rpc/signal_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestGetOrCreateSignal(t *testing.T) {

t.Run("Happy", func(t *testing.T) {
signalManager := mocks.SignalInterface{}
signalManager.OnGetOrCreateSignalMatch(mock.Anything, mock.Anything).Return(&admin.Signal{}, nil)
signalManager.EXPECT().GetOrCreateSignal(mock.Anything, mock.Anything).Return(&admin.Signal{}, nil)

testScope := mockScope.NewTestScope()
mockServer := &SignalService{
Expand All @@ -44,7 +44,7 @@ func TestGetOrCreateSignal(t *testing.T) {

t.Run("ManagerError", func(t *testing.T) {
signalManager := mocks.SignalInterface{}
signalManager.OnGetOrCreateSignalMatch(mock.Anything, mock.Anything).Return(nil, errors.New("foo"))
signalManager.EXPECT().GetOrCreateSignal(mock.Anything, mock.Anything).Return(nil, errors.New("foo"))

testScope := mockScope.NewTestScope()
mockServer := &SignalService{
Expand All @@ -62,7 +62,7 @@ func TestListSignals(t *testing.T) {

t.Run("Happy", func(t *testing.T) {
signalManager := mocks.SignalInterface{}
signalManager.OnListSignalsMatch(mock.Anything, mock.Anything).Return(&admin.SignalList{}, nil)
signalManager.EXPECT().ListSignals(mock.Anything, mock.Anything).Return(&admin.SignalList{}, nil)

testScope := mockScope.NewTestScope()
mockServer := &SignalService{
Expand All @@ -88,7 +88,7 @@ func TestListSignals(t *testing.T) {

t.Run("ManagerError", func(t *testing.T) {
signalManager := mocks.SignalInterface{}
signalManager.OnListSignalsMatch(mock.Anything, mock.Anything).Return(nil, errors.New("foo"))
signalManager.EXPECT().ListSignals(mock.Anything, mock.Anything).Return(nil, errors.New("foo"))

testScope := mockScope.NewTestScope()
mockServer := &SignalService{
Expand All @@ -106,7 +106,7 @@ func TestSetSignal(t *testing.T) {

t.Run("Happy", func(t *testing.T) {
signalManager := mocks.SignalInterface{}
signalManager.OnSetSignalMatch(mock.Anything, mock.Anything).Return(&admin.SignalSetResponse{}, nil)
signalManager.EXPECT().SetSignal(mock.Anything, mock.Anything).Return(&admin.SignalSetResponse{}, nil)

testScope := mockScope.NewTestScope()
mockServer := &SignalService{
Expand All @@ -132,7 +132,7 @@ func TestSetSignal(t *testing.T) {

t.Run("ManagerError", func(t *testing.T) {
signalManager := mocks.SignalInterface{}
signalManager.OnSetSignalMatch(mock.Anything, mock.Anything).Return(nil, errors.New("foo"))
signalManager.EXPECT().SetSignal(mock.Anything, mock.Anything).Return(nil, errors.New("foo"))

testScope := mockScope.NewTestScope()
mockServer := &SignalService{
Expand Down

0 comments on commit 8b12e0a

Please sign in to comment.