diff --git a/Makefile b/Makefile index 58eb2cf3bb..499d94a106 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ DOCKER_PROJECT ?= $(shell echo $(subst $(space),,$(USER_REPO)) | tr -c -s '[:aln DOCKER_COMPOSE_COMMANDS_SUPPORTED := up down config DEFAULT_DOCKER_COMPOSE_COMMAND := up GRPC_MTLS_CERT_FILES_EXISTS = 0 -MOCKERY_VERSION=v2.38.0 +MOCKERY_VERSION=v2.42.1 ifneq ($(MG_MESSAGE_BROKER_TYPE),) MG_MESSAGE_BROKER_TYPE := $(MG_MESSAGE_BROKER_TYPE) else diff --git a/bootstrap/configs.go b/bootstrap/configs.go index 156ee4b876..98c78c447d 100644 --- a/bootstrap/configs.go +++ b/bootstrap/configs.go @@ -60,6 +60,8 @@ type ConfigsPage struct { } // ConfigRepository specifies a Config persistence API. +// +//go:generate mockery --name ConfigRepository --output=./mocks --filename configRepository.go --quiet --note "Copyright (c) Abstract Machines" type ConfigRepository interface { // Save persists the Config. Successful operation is indicated by non-nil // error response. diff --git a/bootstrap/service.go b/bootstrap/service.go index 2f87d1ae57..8712b10368 100644 --- a/bootstrap/service.go +++ b/bootstrap/service.go @@ -50,6 +50,8 @@ var _ Service = (*bootstrapService)(nil) // Service specifies an API that must be fulfilled by the domain service // implementation, and all of its decorators (e.g. logging & metrics). +// +//go:generate mockery --name Service --output=./mocks --filename Service.go --quiet --note "Copyright (c) Abstract Machines" type Service interface { // Add adds new Thing Config to the user identified by the provided token. Add(ctx context.Context, token string, cfg Config) (Config, error) diff --git a/coap/adapter.go b/coap/adapter.go index 1a652da669..8a22398c1a 100644 --- a/coap/adapter.go +++ b/coap/adapter.go @@ -23,8 +23,6 @@ const chansPrefix = "channels" var ErrUnsubscribe = errors.New("unable to unsubscribe") // Service specifies CoAP service API. -// -//go:generate mockery --name Service --output=./mocks --filename service.go --quiet --note "Copyright (c) Abstract Machines" type Service interface { // Publish publishes message to specified channel. // Key is used to authorize publisher. diff --git a/coap/client.go b/coap/client.go index 55f74af1a7..a71d896e56 100644 --- a/coap/client.go +++ b/coap/client.go @@ -18,8 +18,6 @@ import ( ) // Client wraps CoAP client. -// -//go:generate mockery --name Client --output=./mocks --filename client.go --quiet --note "Copyright (c) Abstract Machines" type Client interface { // In CoAP terminology, Token similar to the Session ID. Token() string diff --git a/coap/mocks/client.go b/coap/mocks/client.go deleted file mode 100644 index edbc4017c4..0000000000 --- a/coap/mocks/client.go +++ /dev/null @@ -1,103 +0,0 @@ -// Code generated by mockery v2.42.1. DO NOT EDIT. - -// Copyright (c) Abstract Machines - -package mocks - -import ( - messaging "github.com/absmach/magistrala/pkg/messaging" - mock "github.com/stretchr/testify/mock" -) - -// Client is an autogenerated mock type for the Client type -type Client struct { - mock.Mock -} - -// Cancel provides a mock function with given fields: -func (_m *Client) Cancel() error { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Cancel") - } - - var r0 error - if rf, ok := ret.Get(0).(func() error); ok { - r0 = rf() - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Done provides a mock function with given fields: -func (_m *Client) Done() <-chan struct{} { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Done") - } - - var r0 <-chan struct{} - if rf, ok := ret.Get(0).(func() <-chan struct{}); ok { - r0 = rf() - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(<-chan struct{}) - } - } - - return r0 -} - -// Handle provides a mock function with given fields: m -func (_m *Client) Handle(m *messaging.Message) error { - ret := _m.Called(m) - - if len(ret) == 0 { - panic("no return value specified for Handle") - } - - var r0 error - if rf, ok := ret.Get(0).(func(*messaging.Message) error); ok { - r0 = rf(m) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Token provides a mock function with given fields: -func (_m *Client) Token() string { - ret := _m.Called() - - if len(ret) == 0 { - panic("no return value specified for Token") - } - - var r0 string - if rf, ok := ret.Get(0).(func() string); ok { - r0 = rf() - } else { - r0 = ret.Get(0).(string) - } - - return r0 -} - -// NewClient creates a new instance of Client. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewClient(t interface { - mock.TestingT - Cleanup(func()) -}) *Client { - mock := &Client{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/coap/mocks/service.go b/coap/mocks/service.go deleted file mode 100644 index a72589f77c..0000000000 --- a/coap/mocks/service.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by mockery v2.42.1. DO NOT EDIT. - -// Copyright (c) Abstract Machines - -package mocks - -import ( - context "context" - - coap "github.com/absmach/magistrala/coap" - - messaging "github.com/absmach/magistrala/pkg/messaging" - - mock "github.com/stretchr/testify/mock" -) - -// Service is an autogenerated mock type for the Service type -type Service struct { - mock.Mock -} - -// Publish provides a mock function with given fields: ctx, key, msg -func (_m *Service) Publish(ctx context.Context, key string, msg *messaging.Message) error { - ret := _m.Called(ctx, key, msg) - - if len(ret) == 0 { - panic("no return value specified for Publish") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, *messaging.Message) error); ok { - r0 = rf(ctx, key, msg) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Subscribe provides a mock function with given fields: ctx, key, chanID, subtopic, c -func (_m *Service) Subscribe(ctx context.Context, key string, chanID string, subtopic string, c coap.Client) error { - ret := _m.Called(ctx, key, chanID, subtopic, c) - - if len(ret) == 0 { - panic("no return value specified for Subscribe") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string, coap.Client) error); ok { - r0 = rf(ctx, key, chanID, subtopic, c) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// Unsubscribe provides a mock function with given fields: ctx, key, chanID, subptopic, token -func (_m *Service) Unsubscribe(ctx context.Context, key string, chanID string, subptopic string, token string) error { - ret := _m.Called(ctx, key, chanID, subptopic, token) - - if len(ret) == 0 { - panic("no return value specified for Unsubscribe") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string) error); ok { - r0 = rf(ctx, key, chanID, subptopic, token) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// NewService creates a new instance of Service. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewService(t interface { - mock.TestingT - Cleanup(func()) -}) *Service { - mock := &Service{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/ws/adapter.go b/ws/adapter.go index 6da14a9485..dcc97dee0c 100644 --- a/ws/adapter.go +++ b/ws/adapter.go @@ -43,8 +43,6 @@ var ( ) // Service specifies web socket service API. -// -//go:generate mockery --name Service --output=./mocks --filename service.go --quiet --note "Copyright (c) Abstract Machines" type Service interface { // Subscribe subscribes message from the broker using the thingKey for authorization, // and the channelID for subscription. Subtopic is optional. diff --git a/ws/mocks/service.go b/ws/mocks/service.go deleted file mode 100644 index e3a1c4a577..0000000000 --- a/ws/mocks/service.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by mockery v2.42.1. DO NOT EDIT. - -// Copyright (c) Abstract Machines - -package mocks - -import ( - context "context" - - ws "github.com/absmach/magistrala/ws" - mock "github.com/stretchr/testify/mock" -) - -// Service is an autogenerated mock type for the Service type -type Service struct { - mock.Mock -} - -// Subscribe provides a mock function with given fields: ctx, thingKey, chanID, subtopic, client -func (_m *Service) Subscribe(ctx context.Context, thingKey string, chanID string, subtopic string, client *ws.Client) error { - ret := _m.Called(ctx, thingKey, chanID, subtopic, client) - - if len(ret) == 0 { - panic("no return value specified for Subscribe") - } - - var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string, string, *ws.Client) error); ok { - r0 = rf(ctx, thingKey, chanID, subtopic, client) - } else { - r0 = ret.Error(0) - } - - return r0 -} - -// NewService creates a new instance of Service. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewService(t interface { - mock.TestingT - Cleanup(func()) -}) *Service { - mock := &Service{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -}