mirror of
https://github.com/absmach/magistrala.git
synced 2026-06-23 04:10:28 +00:00
NOISSUE - Revert removal of notifier interface (#2643)
Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
This commit is contained in:
@@ -66,6 +66,7 @@ jobs:
|
||||
- "certs/pki/vault.go"
|
||||
- "certs/service.go"
|
||||
- "journal/journal.go"
|
||||
- "consumers/notifier.go"
|
||||
|
||||
- name: Set up protoc
|
||||
if: steps.changes.outputs.proto == 'true'
|
||||
@@ -162,6 +163,7 @@ jobs:
|
||||
mv ./pkg/events/mocks/publisher.go ./pkg/events/mocks/publisher.go.tmp
|
||||
mv ./pkg/policies/mocks/evaluator.go ./pkg/policies/mocks/evaluator.go.tmp
|
||||
mv ./pkg/policies/mocks/service.go ./pkg/policies/mocks/service.go.tmp
|
||||
mv ./consumers/mocks/notifier.go ./consumers/mocks/notifier.go.tmp
|
||||
|
||||
make mocks
|
||||
|
||||
@@ -220,3 +222,4 @@ jobs:
|
||||
check_mock_changes ./pkg/events/mocks/publisher.go " ./pkg/events/mocks/publisher.go"
|
||||
check_mock_changes ./pkg/policies/mocks/evaluator.go " ./pkg/policies/mocks/evaluator.go"
|
||||
check_mock_changes ./pkg/policies/mocks/service.go " ./pkg/policies/mocks/service.go"
|
||||
check_mock_changes ./consumers/mocks/notifier.go " ./consumers/mocks/notifier.go"
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
// Code generated by mockery v2.43.2. DO NOT EDIT.
|
||||
|
||||
// Copyright (c) Abstract Machines
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
messaging "github.com/absmach/supermq/pkg/messaging"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// Notifier is an autogenerated mock type for the Notifier type
|
||||
type Notifier struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
// Notify provides a mock function with given fields: from, to, msg
|
||||
func (_m *Notifier) Notify(from string, to []string, msg *messaging.Message) error {
|
||||
ret := _m.Called(from, to, msg)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Notify")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, []string, *messaging.Message) error); ok {
|
||||
r0 = rf(from, to, msg)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// NewNotifier creates a new instance of Notifier. 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 NewNotifier(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *Notifier {
|
||||
mock := &Notifier{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) Abstract Machines
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package consumers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/absmach/supermq/pkg/messaging"
|
||||
)
|
||||
|
||||
// ErrNotify wraps sending notification errors.
|
||||
var ErrNotify = errors.New("error sending notification")
|
||||
|
||||
// Notifier represents an API for sending notification.
|
||||
//
|
||||
//go:generate mockery --name Notifier --output=./mocks --filename notifier.go --quiet --note "Copyright (c) Abstract Machines"
|
||||
type Notifier interface {
|
||||
// Notify method is used to send notification for the
|
||||
// received message to the provided list of receivers.
|
||||
Notify(from string, to []string, msg *messaging.Message) error
|
||||
}
|
||||
Reference in New Issue
Block a user