NOISSUE - Update YAML files (#100)

* Rename yml to yaml extensions

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>

* Update Docker project name

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>

* Update SMQ YAML files

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>

* Update Mockery

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>

* Update Mockery version

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>

* Remove mocks before running Mockery

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>

* Update check order

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>

* Fix tests

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>

---------

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
This commit is contained in:
Dušan Borovčanin
2025-04-01 10:41:26 +02:00
committed by GitHub
parent 8f9a496ed6
commit d6477a484f
86 changed files with 5202 additions and 3650 deletions
@@ -36,7 +36,7 @@ jobs:
with:
token: ${{ secrets.CODECOV }}
files: ./coverage/*.out
codecov_yml_path: tools/.codecov.yml
codecov_yml_path: tools/.codecov.yaml
verbose: true
- name: Set up Docker Build
+1 -1
View File
@@ -20,7 +20,7 @@ jobs:
uses: blokovi/swagger-ui-action@main
with:
dir: "./apidocs/openapi"
pattern: "*.yml"
pattern: "*.yaml"
debug: "true"
- name: Deploy to GitHub Pages
@@ -23,13 +23,7 @@ jobs:
go-version: 1.22.x
cache-dependency-path: "go.sum"
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.0.2
args: --config ./tools/config/.golangci.yml
- name: Fetch supermq
- name: Fetch SuperMQ
run: |
make fetch_supermq
if [[ -n $(git status --porcelain docker/supermq-docker) ]]; then
@@ -44,6 +38,13 @@ jobs:
run: |
make all -j $(nproc)
- name: Run linters
uses: golangci/golangci-lint-action@v7
with:
version: v2.0.2
args: --config ./tools/config/.golangci.yaml
run-tests:
name: Run tests
runs-on: ubuntu-latest
@@ -68,7 +69,7 @@ jobs:
base: main
filters: |
workflow:
- ".github/workflows/tests.yml"
- ".github/workflows/tests.yaml"
bootstrap:
- "bootstrap/**"
@@ -180,5 +181,5 @@ jobs:
with:
token: ${{ secrets.CODECOV }}
files: ./coverage/*.out
codecov_yml_path: tools/.codecov.yml
codecov_yml_path: tools/.codecov.yaml
verbose: true
+13 -9
View File
@@ -15,7 +15,7 @@ USER_REPO ?= $(shell git remote get-url origin | sed -E 's#.*[:/]([^/:]+)/([^/.]
empty:=
space:= $(empty) $(empty)
# Docker compose project name should follow this guidelines: https://docs.docker.com/compose/reference/#use--p-to-specify-a-project-name
DOCKER_PROJECT ?= $(shell echo $(subst $(space),,$(USER_REPO)) | tr -c -s '[:alnum:][=-=]' '_' | tr '[:upper:]' '[:lower:]')
DOCKER_PROJECT ?= $(shell echo $(subst $(space),,$(USER_REPO)) | sed -E 's/[^a-zA-Z0-9]/_/g' | tr '[:upper:]' '[:lower:]')
DOCKER_COMPOSE_COMMANDS_SUPPORTED := up down config
DEFAULT_DOCKER_COMPOSE_COMMAND := up
GRPC_MTLS_CERT_FILES_EXISTS = 0
@@ -99,7 +99,7 @@ clean:
cleandocker:
# Stops containers and removes containers, networks, volumes, and images created by up
docker compose -f docker/docker-compose.yml -p $(DOCKER_PROJECT) down --rmi all -v --remove-orphans
docker compose -f docker/docker-compose.yaml -p $(DOCKER_PROJECT) down --rmi all -v --remove-orphans
ifdef pv
# Remove unused volumes
@@ -113,7 +113,11 @@ install:
mocks:
@which mockery > /dev/null || go install github.com/vektra/mockery/v2@$(MOCKERY_VERSION)
@unset MOCKERY_VERSION && go generate ./...
rm -r pkg/sdk/mocks \
bootstrap/mocks \
consumers/notifiers/mocks \
re/mocks \
provision/mocks
mockery --config ./tools/config/.mockery.yaml
@@ -142,7 +146,7 @@ define test_api_service
fi
@if [ "$(svc)" = "http" ]; then \
st run api/openapi/$(svc).yml \
st run api/openapi/$(svc).yaml \
--checks all \
--base-url $(2) \
--header "Authorization: Thing $(THING_SECRET)" \
@@ -150,7 +154,7 @@ define test_api_service
--hypothesis-suppress-health-check=filter_too_much \
--stateful=links; \
else \
st run api/openapi/$(svc).yml \
st run api/openapi/$(svc).yaml \
--checks all \
--base-url $(2) \
--header "Authorization: Bearer $(USER_TOKEN)" \
@@ -250,13 +254,13 @@ fetch_supermq:
@./scripts/supermq.sh
run:
docker compose -f docker/docker-compose.yml \
-f docker/addons/timescale-reader/docker-compose.yml \
-f docker/addons/timescale-writer/docker-compose.yml \
docker compose -f docker/docker-compose.yaml \
-f docker/addons/timescale-reader/docker-compose.yaml \
-f docker/addons/timescale-writer/docker-compose.yaml \
--env-file docker/.env -p $(DOCKER_PROJECT) $(DOCKER_COMPOSE_COMMAND) $(args)
run_addons: check_certs
$(foreach SVC,$(RUN_ADDON_ARGS),$(if $(filter $(SVC),$(ADDON_SERVICES) $(EXTERNAL_SERVICES)),,$(error Invalid Service $(SVC))))
@for SVC in $(RUN_ADDON_ARGS); do \
MG_ADDONS_CERTS_PATH_PREFIX="../." docker compose -f docker/addons/$$SVC/docker-compose.yml -p $(DOCKER_PROJECT) --env-file ./docker/.env $(DOCKER_COMPOSE_COMMAND) $(args) & \
MG_ADDONS_CERTS_PATH_PREFIX="../." docker compose -f docker/addons/$$SVC/docker-compose.yaml -p $(DOCKER_PROJECT) --env-file ./docker/.env $(DOCKER_COMPOSE_COMMAND) $(args) & \
done
+2 -2
View File
@@ -7,7 +7,7 @@
**Scalable • Secure • Open-Source**
[![Check License Header](https://github.com/absmach/magistrala/actions/workflows/check-license.yaml/badge.svg?branch=main)](https://github.com/absmach/magistrala/actions/workflows/check-license.yaml)
[![Continuous Delivery](https://github.com/absmach/magistrala/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/absmach/magistrala/actions/workflows/build.yml)
[![Continuous Delivery](https://github.com/absmach/magistrala/actions/workflows/build.yaml/badge.svg?branch=main)](https://github.com/absmach/magistrala/actions/workflows/build.yaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/absmach/magistrala)](https://goreportcard.com/report/github.com/absmach/magistrala)
[![Coverage](https://codecov.io/gh/absmach/magistrala/graph/badge.svg?token=SEMDAO3L09)](https://codecov.io/gh/absmach/magistrala)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue?style=flat-square)](LICENSE)
@@ -59,7 +59,7 @@ Clone the repository and start the services:
```bash
git clone https://github.com/absmach/magistrala.git
cd magistrala
docker compose -f docker/docker-compose.yml --env-file docker/.env up
docker compose -f docker/docker-compose.yaml --env-file docker/.env up
```
Alternatively, use the Makefile for a simpler command:
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
asyncapi: '2.6.0'
id: 'https://github.com/absmach/magistrala/blob/main/api/asyncapi/mqtt.yml'
id: 'https://github.com/absmach/magistrala/blob/main/api/asyncapi/mqtt.yaml'
info:
title: Magistrala MQTT Adapter
version: '1.0.0'
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
asyncapi: 2.6.0
id: 'https://github.com/absmach/magistrala/blob/main/api/asyncapi/websocket.yml'
id: 'https://github.com/absmach/magistrala/blob/main/api/asyncapi/websocket.yaml'
info:
title: Magistrala WebSocket adapter
description: WebSocket adapter provides a WebSocket API for sending messages through communication channels. WebSocket adapter uses [mProxy](https://github.com/absmach/mproxy) for proxying traffic between client and MQTT broker.
@@ -662,7 +662,7 @@ components:
content:
application/health+json:
schema:
$ref: "./schemas/health_info.yml"
$ref: "./schemas/health_info.yaml"
ConfigUpdateCertsRes:
description: Data retrieved. Config certs updated.
content:
@@ -278,7 +278,7 @@ components:
content:
application/health+json:
schema:
$ref: "./schemas/health_info.yml"
$ref: "./schemas/health_info.yaml"
securitySchemes:
bearerAuth:
@@ -292,7 +292,7 @@ components:
content:
application/health+json:
schema:
$ref: "./schemas/health_info.yml"
$ref: "./schemas/health_info.yaml"
securitySchemes:
bearerAuth:
@@ -516,7 +516,7 @@ components:
content:
application/health+json:
schema:
$ref: "./schemas/health_info.yml"
$ref: "./schemas/health_info.yaml"
securitySchemes:
bearerAuth:
+2 -2
View File
@@ -67,7 +67,7 @@ The service is configured using the environment variables presented in the follo
## Deployment
The service itself is distributed as Docker container. Check the [`bootstrap`](https://github.com/absmach/magistrala/blob/main/docker/addons/bootstrap/docker-compose.yml) service section in docker-compose file to see how service is deployed.
The service itself is distributed as Docker container. Check the [`bootstrap`](https://github.com/absmach/magistrala/blob/main/docker/addons/bootstrap/docker-compose.yaml) service section in docker-compose file to see how service is deployed.
To start the service outside of the container, execute the following shell script:
@@ -119,4 +119,4 @@ Setting `SMQ_AUTH_GRPC_CLIENT_CERT` and `SMQ_AUTH_GRPC_CLIENT_KEY` will enable T
## Usage
For more information about service capabilities and its usage, please check out the [API documentation](https://docs.api.magistrala.abstractmachines.fr/?urls.primaryName=bootstrap.yml).
For more information about service capabilities and its usage, please check out the [API documentation](https://docs.api.magistrala.abstractmachines.fr/?urls.primaryName=bootstrap.yaml).
+3 -3
View File
@@ -20,7 +20,7 @@ import (
"github.com/absmach/magistrala/bootstrap"
bsapi "github.com/absmach/magistrala/bootstrap/api"
"github.com/absmach/magistrala/bootstrap/mocks"
mocks "github.com/absmach/magistrala/bootstrap/mocks"
"github.com/absmach/magistrala/internal/testsutil"
apiutil "github.com/absmach/supermq/api/http/util"
smqlog "github.com/absmach/supermq/logger"
@@ -176,9 +176,9 @@ func dec(in []byte) ([]byte, error) {
return in, nil
}
func newBootstrapServer() (*httptest.Server, *mocks.Service, *authnmocks.Authentication) {
func newBootstrapServer() (*httptest.Server, *mocks.MockService, *authnmocks.Authentication) {
logger := smqlog.NewMock()
svc := new(mocks.Service)
svc := new(mocks.MockService)
authn := new(authnmocks.Authentication)
mux := bsapi.MakeHandler(svc, authn, bootstrap.NewConfigReader(encKey), logger, instanceID)
return httptest.NewServer(mux), svc, authn
-2
View File
@@ -60,8 +60,6 @@ type ConfigsPage struct {
}
// ConfigRepository specifies a Config persistence API.
//
//go:generate mockery --name ConfigRepository --output=./mocks --filename configs.go --quiet --note "Copyright (c) Abstract Machines"
type ConfigRepository interface {
// Save persists the Config. Successful operation is indicated by non-nil
// error response.
+3 -3
View File
@@ -13,7 +13,7 @@ import (
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/bootstrap/events/producer"
"github.com/absmach/magistrala/bootstrap/mocks"
mocks "github.com/absmach/magistrala/bootstrap/mocks"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/supermq/pkg/authn"
smqauthn "github.com/absmach/supermq/pkg/authn"
@@ -87,13 +87,13 @@ var (
type testVariable struct {
svc bootstrap.Service
boot *mocks.ConfigRepository
boot *mocks.MockConfigRepository
policies *policymocks.Service
sdk *sdkmocks.SDK
}
func newTestVariable(t *testing.T, redisURL string) testVariable {
boot := new(mocks.ConfigRepository)
boot := new(mocks.MockConfigRepository)
policies := new(policymocks.Service)
sdk := new(sdkmocks.SDK)
idp := uuid.NewMock()
-59
View File
@@ -1,59 +0,0 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Copyright (c) Abstract Machines
package mocks
import (
bootstrap "github.com/absmach/magistrala/bootstrap"
mock "github.com/stretchr/testify/mock"
)
// ConfigReader is an autogenerated mock type for the ConfigReader type
type ConfigReader struct {
mock.Mock
}
// ReadConfig provides a mock function with given fields: _a0, _a1
func (_m *ConfigReader) ReadConfig(_a0 bootstrap.Config, _a1 bool) (interface{}, error) {
ret := _m.Called(_a0, _a1)
if len(ret) == 0 {
panic("no return value specified for ReadConfig")
}
var r0 interface{}
var r1 error
if rf, ok := ret.Get(0).(func(bootstrap.Config, bool) (interface{}, error)); ok {
return rf(_a0, _a1)
}
if rf, ok := ret.Get(0).(func(bootstrap.Config, bool) interface{}); ok {
r0 = rf(_a0, _a1)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(interface{})
}
}
if rf, ok := ret.Get(1).(func(bootstrap.Config, bool) error); ok {
r1 = rf(_a0, _a1)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// NewConfigReader creates a new instance of ConfigReader. 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 NewConfigReader(t interface {
mock.TestingT
Cleanup(func())
}) *ConfigReader {
mock := &ConfigReader{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
-354
View File
@@ -1,354 +0,0 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Copyright (c) Abstract Machines
package mocks
import (
context "context"
bootstrap "github.com/absmach/magistrala/bootstrap"
mock "github.com/stretchr/testify/mock"
)
// ConfigRepository is an autogenerated mock type for the ConfigRepository type
type ConfigRepository struct {
mock.Mock
}
// ChangeState provides a mock function with given fields: ctx, domainID, id, state
func (_m *ConfigRepository) ChangeState(ctx context.Context, domainID string, id string, state bootstrap.State) error {
ret := _m.Called(ctx, domainID, id, state)
if len(ret) == 0 {
panic("no return value specified for ChangeState")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, bootstrap.State) error); ok {
r0 = rf(ctx, domainID, id, state)
} else {
r0 = ret.Error(0)
}
return r0
}
// ConnectClient provides a mock function with given fields: ctx, channelID, clientID
func (_m *ConfigRepository) ConnectClient(ctx context.Context, channelID string, clientID string) error {
ret := _m.Called(ctx, channelID, clientID)
if len(ret) == 0 {
panic("no return value specified for ConnectClient")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = rf(ctx, channelID, clientID)
} else {
r0 = ret.Error(0)
}
return r0
}
// DisconnectClient provides a mock function with given fields: ctx, channelID, clientID
func (_m *ConfigRepository) DisconnectClient(ctx context.Context, channelID string, clientID string) error {
ret := _m.Called(ctx, channelID, clientID)
if len(ret) == 0 {
panic("no return value specified for DisconnectClient")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = rf(ctx, channelID, clientID)
} else {
r0 = ret.Error(0)
}
return r0
}
// ListExisting provides a mock function with given fields: ctx, domainID, ids
func (_m *ConfigRepository) ListExisting(ctx context.Context, domainID string, ids []string) ([]bootstrap.Channel, error) {
ret := _m.Called(ctx, domainID, ids)
if len(ret) == 0 {
panic("no return value specified for ListExisting")
}
var r0 []bootstrap.Channel
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, []string) ([]bootstrap.Channel, error)); ok {
return rf(ctx, domainID, ids)
}
if rf, ok := ret.Get(0).(func(context.Context, string, []string) []bootstrap.Channel); ok {
r0 = rf(ctx, domainID, ids)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]bootstrap.Channel)
}
}
if rf, ok := ret.Get(1).(func(context.Context, string, []string) error); ok {
r1 = rf(ctx, domainID, ids)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Remove provides a mock function with given fields: ctx, domainID, id
func (_m *ConfigRepository) Remove(ctx context.Context, domainID string, id string) error {
ret := _m.Called(ctx, domainID, id)
if len(ret) == 0 {
panic("no return value specified for Remove")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = rf(ctx, domainID, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// RemoveChannel provides a mock function with given fields: ctx, id
func (_m *ConfigRepository) RemoveChannel(ctx context.Context, id string) error {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for RemoveChannel")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// RemoveClient provides a mock function with given fields: ctx, id
func (_m *ConfigRepository) RemoveClient(ctx context.Context, id string) error {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for RemoveClient")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// RetrieveAll provides a mock function with given fields: ctx, domainID, clientIDs, filter, offset, limit
func (_m *ConfigRepository) RetrieveAll(ctx context.Context, domainID string, clientIDs []string, filter bootstrap.Filter, offset uint64, limit uint64) bootstrap.ConfigsPage {
ret := _m.Called(ctx, domainID, clientIDs, filter, offset, limit)
if len(ret) == 0 {
panic("no return value specified for RetrieveAll")
}
var r0 bootstrap.ConfigsPage
if rf, ok := ret.Get(0).(func(context.Context, string, []string, bootstrap.Filter, uint64, uint64) bootstrap.ConfigsPage); ok {
r0 = rf(ctx, domainID, clientIDs, filter, offset, limit)
} else {
r0 = ret.Get(0).(bootstrap.ConfigsPage)
}
return r0
}
// RetrieveByExternalID provides a mock function with given fields: ctx, externalID
func (_m *ConfigRepository) RetrieveByExternalID(ctx context.Context, externalID string) (bootstrap.Config, error) {
ret := _m.Called(ctx, externalID)
if len(ret) == 0 {
panic("no return value specified for RetrieveByExternalID")
}
var r0 bootstrap.Config
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string) (bootstrap.Config, error)); ok {
return rf(ctx, externalID)
}
if rf, ok := ret.Get(0).(func(context.Context, string) bootstrap.Config); ok {
r0 = rf(ctx, externalID)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
r1 = rf(ctx, externalID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// RetrieveByID provides a mock function with given fields: ctx, domainID, id
func (_m *ConfigRepository) RetrieveByID(ctx context.Context, domainID string, id string) (bootstrap.Config, error) {
ret := _m.Called(ctx, domainID, id)
if len(ret) == 0 {
panic("no return value specified for RetrieveByID")
}
var r0 bootstrap.Config
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) (bootstrap.Config, error)); ok {
return rf(ctx, domainID, id)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string) bootstrap.Config); ok {
r0 = rf(ctx, domainID, id)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
r1 = rf(ctx, domainID, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Save provides a mock function with given fields: ctx, cfg, chsConnIDs
func (_m *ConfigRepository) Save(ctx context.Context, cfg bootstrap.Config, chsConnIDs []string) (string, error) {
ret := _m.Called(ctx, cfg, chsConnIDs)
if len(ret) == 0 {
panic("no return value specified for Save")
}
var r0 string
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, bootstrap.Config, []string) (string, error)); ok {
return rf(ctx, cfg, chsConnIDs)
}
if rf, ok := ret.Get(0).(func(context.Context, bootstrap.Config, []string) string); ok {
r0 = rf(ctx, cfg, chsConnIDs)
} else {
r0 = ret.Get(0).(string)
}
if rf, ok := ret.Get(1).(func(context.Context, bootstrap.Config, []string) error); ok {
r1 = rf(ctx, cfg, chsConnIDs)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Update provides a mock function with given fields: ctx, cfg
func (_m *ConfigRepository) Update(ctx context.Context, cfg bootstrap.Config) error {
ret := _m.Called(ctx, cfg)
if len(ret) == 0 {
panic("no return value specified for Update")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, bootstrap.Config) error); ok {
r0 = rf(ctx, cfg)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateCert provides a mock function with given fields: ctx, domainID, clientID, clientCert, clientKey, caCert
func (_m *ConfigRepository) UpdateCert(ctx context.Context, domainID string, clientID string, clientCert string, clientKey string, caCert string) (bootstrap.Config, error) {
ret := _m.Called(ctx, domainID, clientID, clientCert, clientKey, caCert)
if len(ret) == 0 {
panic("no return value specified for UpdateCert")
}
var r0 bootstrap.Config
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string, string) (bootstrap.Config, error)); ok {
return rf(ctx, domainID, clientID, clientCert, clientKey, caCert)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string, string) bootstrap.Config); ok {
r0 = rf(ctx, domainID, clientID, clientCert, clientKey, caCert)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if rf, ok := ret.Get(1).(func(context.Context, string, string, string, string, string) error); ok {
r1 = rf(ctx, domainID, clientID, clientCert, clientKey, caCert)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UpdateChannel provides a mock function with given fields: ctx, c
func (_m *ConfigRepository) UpdateChannel(ctx context.Context, c bootstrap.Channel) error {
ret := _m.Called(ctx, c)
if len(ret) == 0 {
panic("no return value specified for UpdateChannel")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, bootstrap.Channel) error); ok {
r0 = rf(ctx, c)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateConnections provides a mock function with given fields: ctx, domainID, id, channels, connections
func (_m *ConfigRepository) UpdateConnections(ctx context.Context, domainID string, id string, channels []bootstrap.Channel, connections []string) error {
ret := _m.Called(ctx, domainID, id, channels, connections)
if len(ret) == 0 {
panic("no return value specified for UpdateConnections")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, []bootstrap.Channel, []string) error); ok {
r0 = rf(ctx, domainID, id, channels, connections)
} else {
r0 = ret.Error(0)
}
return r0
}
// NewConfigRepository creates a new instance of ConfigRepository. 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 NewConfigRepository(t interface {
mock.TestingT
Cleanup(func())
}) *ConfigRepository {
mock := &ConfigRepository{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
-5
View File
@@ -1,5 +0,0 @@
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0
// Package mocks contains mocks for testing purposes.
package mocks
+94
View File
@@ -0,0 +1,94 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package bootstrap
import (
"github.com/absmach/magistrala/bootstrap"
mock "github.com/stretchr/testify/mock"
)
// NewMockConfigReader creates a new instance of MockConfigReader. 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 NewMockConfigReader(t interface {
mock.TestingT
Cleanup(func())
}) *MockConfigReader {
mock := &MockConfigReader{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockConfigReader is an autogenerated mock type for the ConfigReader type
type MockConfigReader struct {
mock.Mock
}
type MockConfigReader_Expecter struct {
mock *mock.Mock
}
func (_m *MockConfigReader) EXPECT() *MockConfigReader_Expecter {
return &MockConfigReader_Expecter{mock: &_m.Mock}
}
// ReadConfig provides a mock function for the type MockConfigReader
func (_mock *MockConfigReader) ReadConfig(config bootstrap.Config, b bool) (interface{}, error) {
ret := _mock.Called(config, b)
if len(ret) == 0 {
panic("no return value specified for ReadConfig")
}
var r0 interface{}
var r1 error
if returnFunc, ok := ret.Get(0).(func(bootstrap.Config, bool) (interface{}, error)); ok {
return returnFunc(config, b)
}
if returnFunc, ok := ret.Get(0).(func(bootstrap.Config, bool) interface{}); ok {
r0 = returnFunc(config, b)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(interface{})
}
}
if returnFunc, ok := ret.Get(1).(func(bootstrap.Config, bool) error); ok {
r1 = returnFunc(config, b)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockConfigReader_ReadConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReadConfig'
type MockConfigReader_ReadConfig_Call struct {
*mock.Call
}
// ReadConfig is a helper method to define mock.On call
// - config
// - b
func (_e *MockConfigReader_Expecter) ReadConfig(config interface{}, b interface{}) *MockConfigReader_ReadConfig_Call {
return &MockConfigReader_ReadConfig_Call{Call: _e.mock.On("ReadConfig", config, b)}
}
func (_c *MockConfigReader_ReadConfig_Call) Run(run func(config bootstrap.Config, b bool)) *MockConfigReader_ReadConfig_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(bootstrap.Config), args[1].(bool))
})
return _c
}
func (_c *MockConfigReader_ReadConfig_Call) Return(ifaceVal interface{}, err error) *MockConfigReader_ReadConfig_Call {
_c.Call.Return(ifaceVal, err)
return _c
}
func (_c *MockConfigReader_ReadConfig_Call) RunAndReturn(run func(config bootstrap.Config, b bool) (interface{}, error)) *MockConfigReader_ReadConfig_Call {
_c.Call.Return(run)
return _c
}
+795
View File
@@ -0,0 +1,795 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package bootstrap
import (
"context"
"github.com/absmach/magistrala/bootstrap"
mock "github.com/stretchr/testify/mock"
)
// NewMockConfigRepository creates a new instance of MockConfigRepository. 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 NewMockConfigRepository(t interface {
mock.TestingT
Cleanup(func())
}) *MockConfigRepository {
mock := &MockConfigRepository{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockConfigRepository is an autogenerated mock type for the ConfigRepository type
type MockConfigRepository struct {
mock.Mock
}
type MockConfigRepository_Expecter struct {
mock *mock.Mock
}
func (_m *MockConfigRepository) EXPECT() *MockConfigRepository_Expecter {
return &MockConfigRepository_Expecter{mock: &_m.Mock}
}
// ChangeState provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) ChangeState(ctx context.Context, domainID string, id string, state bootstrap.State) error {
ret := _mock.Called(ctx, domainID, id, state)
if len(ret) == 0 {
panic("no return value specified for ChangeState")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, bootstrap.State) error); ok {
r0 = returnFunc(ctx, domainID, id, state)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_ChangeState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeState'
type MockConfigRepository_ChangeState_Call struct {
*mock.Call
}
// ChangeState is a helper method to define mock.On call
// - ctx
// - domainID
// - id
// - state
func (_e *MockConfigRepository_Expecter) ChangeState(ctx interface{}, domainID interface{}, id interface{}, state interface{}) *MockConfigRepository_ChangeState_Call {
return &MockConfigRepository_ChangeState_Call{Call: _e.mock.On("ChangeState", ctx, domainID, id, state)}
}
func (_c *MockConfigRepository_ChangeState_Call) Run(run func(ctx context.Context, domainID string, id string, state bootstrap.State)) *MockConfigRepository_ChangeState_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(bootstrap.State))
})
return _c
}
func (_c *MockConfigRepository_ChangeState_Call) Return(err error) *MockConfigRepository_ChangeState_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_ChangeState_Call) RunAndReturn(run func(ctx context.Context, domainID string, id string, state bootstrap.State) error) *MockConfigRepository_ChangeState_Call {
_c.Call.Return(run)
return _c
}
// ConnectClient provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) ConnectClient(ctx context.Context, channelID string, clientID string) error {
ret := _mock.Called(ctx, channelID, clientID)
if len(ret) == 0 {
panic("no return value specified for ConnectClient")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = returnFunc(ctx, channelID, clientID)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_ConnectClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConnectClient'
type MockConfigRepository_ConnectClient_Call struct {
*mock.Call
}
// ConnectClient is a helper method to define mock.On call
// - ctx
// - channelID
// - clientID
func (_e *MockConfigRepository_Expecter) ConnectClient(ctx interface{}, channelID interface{}, clientID interface{}) *MockConfigRepository_ConnectClient_Call {
return &MockConfigRepository_ConnectClient_Call{Call: _e.mock.On("ConnectClient", ctx, channelID, clientID)}
}
func (_c *MockConfigRepository_ConnectClient_Call) Run(run func(ctx context.Context, channelID string, clientID string)) *MockConfigRepository_ConnectClient_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string))
})
return _c
}
func (_c *MockConfigRepository_ConnectClient_Call) Return(err error) *MockConfigRepository_ConnectClient_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_ConnectClient_Call) RunAndReturn(run func(ctx context.Context, channelID string, clientID string) error) *MockConfigRepository_ConnectClient_Call {
_c.Call.Return(run)
return _c
}
// DisconnectClient provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) DisconnectClient(ctx context.Context, channelID string, clientID string) error {
ret := _mock.Called(ctx, channelID, clientID)
if len(ret) == 0 {
panic("no return value specified for DisconnectClient")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = returnFunc(ctx, channelID, clientID)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_DisconnectClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DisconnectClient'
type MockConfigRepository_DisconnectClient_Call struct {
*mock.Call
}
// DisconnectClient is a helper method to define mock.On call
// - ctx
// - channelID
// - clientID
func (_e *MockConfigRepository_Expecter) DisconnectClient(ctx interface{}, channelID interface{}, clientID interface{}) *MockConfigRepository_DisconnectClient_Call {
return &MockConfigRepository_DisconnectClient_Call{Call: _e.mock.On("DisconnectClient", ctx, channelID, clientID)}
}
func (_c *MockConfigRepository_DisconnectClient_Call) Run(run func(ctx context.Context, channelID string, clientID string)) *MockConfigRepository_DisconnectClient_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string))
})
return _c
}
func (_c *MockConfigRepository_DisconnectClient_Call) Return(err error) *MockConfigRepository_DisconnectClient_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_DisconnectClient_Call) RunAndReturn(run func(ctx context.Context, channelID string, clientID string) error) *MockConfigRepository_DisconnectClient_Call {
_c.Call.Return(run)
return _c
}
// ListExisting provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) ListExisting(ctx context.Context, domainID string, ids []string) ([]bootstrap.Channel, error) {
ret := _mock.Called(ctx, domainID, ids)
if len(ret) == 0 {
panic("no return value specified for ListExisting")
}
var r0 []bootstrap.Channel
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, []string) ([]bootstrap.Channel, error)); ok {
return returnFunc(ctx, domainID, ids)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, string, []string) []bootstrap.Channel); ok {
r0 = returnFunc(ctx, domainID, ids)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).([]bootstrap.Channel)
}
}
if returnFunc, ok := ret.Get(1).(func(context.Context, string, []string) error); ok {
r1 = returnFunc(ctx, domainID, ids)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockConfigRepository_ListExisting_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListExisting'
type MockConfigRepository_ListExisting_Call struct {
*mock.Call
}
// ListExisting is a helper method to define mock.On call
// - ctx
// - domainID
// - ids
func (_e *MockConfigRepository_Expecter) ListExisting(ctx interface{}, domainID interface{}, ids interface{}) *MockConfigRepository_ListExisting_Call {
return &MockConfigRepository_ListExisting_Call{Call: _e.mock.On("ListExisting", ctx, domainID, ids)}
}
func (_c *MockConfigRepository_ListExisting_Call) Run(run func(ctx context.Context, domainID string, ids []string)) *MockConfigRepository_ListExisting_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].([]string))
})
return _c
}
func (_c *MockConfigRepository_ListExisting_Call) Return(channels []bootstrap.Channel, err error) *MockConfigRepository_ListExisting_Call {
_c.Call.Return(channels, err)
return _c
}
func (_c *MockConfigRepository_ListExisting_Call) RunAndReturn(run func(ctx context.Context, domainID string, ids []string) ([]bootstrap.Channel, error)) *MockConfigRepository_ListExisting_Call {
_c.Call.Return(run)
return _c
}
// Remove provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) Remove(ctx context.Context, domainID string, id string) error {
ret := _mock.Called(ctx, domainID, id)
if len(ret) == 0 {
panic("no return value specified for Remove")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = returnFunc(ctx, domainID, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove'
type MockConfigRepository_Remove_Call struct {
*mock.Call
}
// Remove is a helper method to define mock.On call
// - ctx
// - domainID
// - id
func (_e *MockConfigRepository_Expecter) Remove(ctx interface{}, domainID interface{}, id interface{}) *MockConfigRepository_Remove_Call {
return &MockConfigRepository_Remove_Call{Call: _e.mock.On("Remove", ctx, domainID, id)}
}
func (_c *MockConfigRepository_Remove_Call) Run(run func(ctx context.Context, domainID string, id string)) *MockConfigRepository_Remove_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string))
})
return _c
}
func (_c *MockConfigRepository_Remove_Call) Return(err error) *MockConfigRepository_Remove_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_Remove_Call) RunAndReturn(run func(ctx context.Context, domainID string, id string) error) *MockConfigRepository_Remove_Call {
_c.Call.Return(run)
return _c
}
// RemoveChannel provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) RemoveChannel(ctx context.Context, id string) error {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for RemoveChannel")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_RemoveChannel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveChannel'
type MockConfigRepository_RemoveChannel_Call struct {
*mock.Call
}
// RemoveChannel is a helper method to define mock.On call
// - ctx
// - id
func (_e *MockConfigRepository_Expecter) RemoveChannel(ctx interface{}, id interface{}) *MockConfigRepository_RemoveChannel_Call {
return &MockConfigRepository_RemoveChannel_Call{Call: _e.mock.On("RemoveChannel", ctx, id)}
}
func (_c *MockConfigRepository_RemoveChannel_Call) Run(run func(ctx context.Context, id string)) *MockConfigRepository_RemoveChannel_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockConfigRepository_RemoveChannel_Call) Return(err error) *MockConfigRepository_RemoveChannel_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_RemoveChannel_Call) RunAndReturn(run func(ctx context.Context, id string) error) *MockConfigRepository_RemoveChannel_Call {
_c.Call.Return(run)
return _c
}
// RemoveClient provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) RemoveClient(ctx context.Context, id string) error {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for RemoveClient")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_RemoveClient_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveClient'
type MockConfigRepository_RemoveClient_Call struct {
*mock.Call
}
// RemoveClient is a helper method to define mock.On call
// - ctx
// - id
func (_e *MockConfigRepository_Expecter) RemoveClient(ctx interface{}, id interface{}) *MockConfigRepository_RemoveClient_Call {
return &MockConfigRepository_RemoveClient_Call{Call: _e.mock.On("RemoveClient", ctx, id)}
}
func (_c *MockConfigRepository_RemoveClient_Call) Run(run func(ctx context.Context, id string)) *MockConfigRepository_RemoveClient_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockConfigRepository_RemoveClient_Call) Return(err error) *MockConfigRepository_RemoveClient_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_RemoveClient_Call) RunAndReturn(run func(ctx context.Context, id string) error) *MockConfigRepository_RemoveClient_Call {
_c.Call.Return(run)
return _c
}
// RetrieveAll provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) RetrieveAll(ctx context.Context, domainID string, clientIDs []string, filter bootstrap.Filter, offset uint64, limit uint64) bootstrap.ConfigsPage {
ret := _mock.Called(ctx, domainID, clientIDs, filter, offset, limit)
if len(ret) == 0 {
panic("no return value specified for RetrieveAll")
}
var r0 bootstrap.ConfigsPage
if returnFunc, ok := ret.Get(0).(func(context.Context, string, []string, bootstrap.Filter, uint64, uint64) bootstrap.ConfigsPage); ok {
r0 = returnFunc(ctx, domainID, clientIDs, filter, offset, limit)
} else {
r0 = ret.Get(0).(bootstrap.ConfigsPage)
}
return r0
}
// MockConfigRepository_RetrieveAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RetrieveAll'
type MockConfigRepository_RetrieveAll_Call struct {
*mock.Call
}
// RetrieveAll is a helper method to define mock.On call
// - ctx
// - domainID
// - clientIDs
// - filter
// - offset
// - limit
func (_e *MockConfigRepository_Expecter) RetrieveAll(ctx interface{}, domainID interface{}, clientIDs interface{}, filter interface{}, offset interface{}, limit interface{}) *MockConfigRepository_RetrieveAll_Call {
return &MockConfigRepository_RetrieveAll_Call{Call: _e.mock.On("RetrieveAll", ctx, domainID, clientIDs, filter, offset, limit)}
}
func (_c *MockConfigRepository_RetrieveAll_Call) Run(run func(ctx context.Context, domainID string, clientIDs []string, filter bootstrap.Filter, offset uint64, limit uint64)) *MockConfigRepository_RetrieveAll_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].([]string), args[3].(bootstrap.Filter), args[4].(uint64), args[5].(uint64))
})
return _c
}
func (_c *MockConfigRepository_RetrieveAll_Call) Return(configsPage bootstrap.ConfigsPage) *MockConfigRepository_RetrieveAll_Call {
_c.Call.Return(configsPage)
return _c
}
func (_c *MockConfigRepository_RetrieveAll_Call) RunAndReturn(run func(ctx context.Context, domainID string, clientIDs []string, filter bootstrap.Filter, offset uint64, limit uint64) bootstrap.ConfigsPage) *MockConfigRepository_RetrieveAll_Call {
_c.Call.Return(run)
return _c
}
// RetrieveByExternalID provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) RetrieveByExternalID(ctx context.Context, externalID string) (bootstrap.Config, error) {
ret := _mock.Called(ctx, externalID)
if len(ret) == 0 {
panic("no return value specified for RetrieveByExternalID")
}
var r0 bootstrap.Config
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string) (bootstrap.Config, error)); ok {
return returnFunc(ctx, externalID)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, string) bootstrap.Config); ok {
r0 = returnFunc(ctx, externalID)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
r1 = returnFunc(ctx, externalID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockConfigRepository_RetrieveByExternalID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RetrieveByExternalID'
type MockConfigRepository_RetrieveByExternalID_Call struct {
*mock.Call
}
// RetrieveByExternalID is a helper method to define mock.On call
// - ctx
// - externalID
func (_e *MockConfigRepository_Expecter) RetrieveByExternalID(ctx interface{}, externalID interface{}) *MockConfigRepository_RetrieveByExternalID_Call {
return &MockConfigRepository_RetrieveByExternalID_Call{Call: _e.mock.On("RetrieveByExternalID", ctx, externalID)}
}
func (_c *MockConfigRepository_RetrieveByExternalID_Call) Run(run func(ctx context.Context, externalID string)) *MockConfigRepository_RetrieveByExternalID_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockConfigRepository_RetrieveByExternalID_Call) Return(config bootstrap.Config, err error) *MockConfigRepository_RetrieveByExternalID_Call {
_c.Call.Return(config, err)
return _c
}
func (_c *MockConfigRepository_RetrieveByExternalID_Call) RunAndReturn(run func(ctx context.Context, externalID string) (bootstrap.Config, error)) *MockConfigRepository_RetrieveByExternalID_Call {
_c.Call.Return(run)
return _c
}
// RetrieveByID provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) RetrieveByID(ctx context.Context, domainID string, id string) (bootstrap.Config, error) {
ret := _mock.Called(ctx, domainID, id)
if len(ret) == 0 {
panic("no return value specified for RetrieveByID")
}
var r0 bootstrap.Config
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) (bootstrap.Config, error)); ok {
return returnFunc(ctx, domainID, id)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) bootstrap.Config); ok {
r0 = returnFunc(ctx, domainID, id)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
r1 = returnFunc(ctx, domainID, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockConfigRepository_RetrieveByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RetrieveByID'
type MockConfigRepository_RetrieveByID_Call struct {
*mock.Call
}
// RetrieveByID is a helper method to define mock.On call
// - ctx
// - domainID
// - id
func (_e *MockConfigRepository_Expecter) RetrieveByID(ctx interface{}, domainID interface{}, id interface{}) *MockConfigRepository_RetrieveByID_Call {
return &MockConfigRepository_RetrieveByID_Call{Call: _e.mock.On("RetrieveByID", ctx, domainID, id)}
}
func (_c *MockConfigRepository_RetrieveByID_Call) Run(run func(ctx context.Context, domainID string, id string)) *MockConfigRepository_RetrieveByID_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string))
})
return _c
}
func (_c *MockConfigRepository_RetrieveByID_Call) Return(config bootstrap.Config, err error) *MockConfigRepository_RetrieveByID_Call {
_c.Call.Return(config, err)
return _c
}
func (_c *MockConfigRepository_RetrieveByID_Call) RunAndReturn(run func(ctx context.Context, domainID string, id string) (bootstrap.Config, error)) *MockConfigRepository_RetrieveByID_Call {
_c.Call.Return(run)
return _c
}
// Save provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) Save(ctx context.Context, cfg bootstrap.Config, chsConnIDs []string) (string, error) {
ret := _mock.Called(ctx, cfg, chsConnIDs)
if len(ret) == 0 {
panic("no return value specified for Save")
}
var r0 string
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, bootstrap.Config, []string) (string, error)); ok {
return returnFunc(ctx, cfg, chsConnIDs)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, bootstrap.Config, []string) string); ok {
r0 = returnFunc(ctx, cfg, chsConnIDs)
} else {
r0 = ret.Get(0).(string)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, bootstrap.Config, []string) error); ok {
r1 = returnFunc(ctx, cfg, chsConnIDs)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockConfigRepository_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save'
type MockConfigRepository_Save_Call struct {
*mock.Call
}
// Save is a helper method to define mock.On call
// - ctx
// - cfg
// - chsConnIDs
func (_e *MockConfigRepository_Expecter) Save(ctx interface{}, cfg interface{}, chsConnIDs interface{}) *MockConfigRepository_Save_Call {
return &MockConfigRepository_Save_Call{Call: _e.mock.On("Save", ctx, cfg, chsConnIDs)}
}
func (_c *MockConfigRepository_Save_Call) Run(run func(ctx context.Context, cfg bootstrap.Config, chsConnIDs []string)) *MockConfigRepository_Save_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(bootstrap.Config), args[2].([]string))
})
return _c
}
func (_c *MockConfigRepository_Save_Call) Return(s string, err error) *MockConfigRepository_Save_Call {
_c.Call.Return(s, err)
return _c
}
func (_c *MockConfigRepository_Save_Call) RunAndReturn(run func(ctx context.Context, cfg bootstrap.Config, chsConnIDs []string) (string, error)) *MockConfigRepository_Save_Call {
_c.Call.Return(run)
return _c
}
// Update provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) Update(ctx context.Context, cfg bootstrap.Config) error {
ret := _mock.Called(ctx, cfg)
if len(ret) == 0 {
panic("no return value specified for Update")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, bootstrap.Config) error); ok {
r0 = returnFunc(ctx, cfg)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update'
type MockConfigRepository_Update_Call struct {
*mock.Call
}
// Update is a helper method to define mock.On call
// - ctx
// - cfg
func (_e *MockConfigRepository_Expecter) Update(ctx interface{}, cfg interface{}) *MockConfigRepository_Update_Call {
return &MockConfigRepository_Update_Call{Call: _e.mock.On("Update", ctx, cfg)}
}
func (_c *MockConfigRepository_Update_Call) Run(run func(ctx context.Context, cfg bootstrap.Config)) *MockConfigRepository_Update_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(bootstrap.Config))
})
return _c
}
func (_c *MockConfigRepository_Update_Call) Return(err error) *MockConfigRepository_Update_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_Update_Call) RunAndReturn(run func(ctx context.Context, cfg bootstrap.Config) error) *MockConfigRepository_Update_Call {
_c.Call.Return(run)
return _c
}
// UpdateCert provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) UpdateCert(ctx context.Context, domainID string, clientID string, clientCert string, clientKey string, caCert string) (bootstrap.Config, error) {
ret := _mock.Called(ctx, domainID, clientID, clientCert, clientKey, caCert)
if len(ret) == 0 {
panic("no return value specified for UpdateCert")
}
var r0 bootstrap.Config
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, string, string, string) (bootstrap.Config, error)); ok {
return returnFunc(ctx, domainID, clientID, clientCert, clientKey, caCert)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, string, string, string) bootstrap.Config); ok {
r0 = returnFunc(ctx, domainID, clientID, clientCert, clientKey, caCert)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, string, string, string, string, string) error); ok {
r1 = returnFunc(ctx, domainID, clientID, clientCert, clientKey, caCert)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockConfigRepository_UpdateCert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateCert'
type MockConfigRepository_UpdateCert_Call struct {
*mock.Call
}
// UpdateCert is a helper method to define mock.On call
// - ctx
// - domainID
// - clientID
// - clientCert
// - clientKey
// - caCert
func (_e *MockConfigRepository_Expecter) UpdateCert(ctx interface{}, domainID interface{}, clientID interface{}, clientCert interface{}, clientKey interface{}, caCert interface{}) *MockConfigRepository_UpdateCert_Call {
return &MockConfigRepository_UpdateCert_Call{Call: _e.mock.On("UpdateCert", ctx, domainID, clientID, clientCert, clientKey, caCert)}
}
func (_c *MockConfigRepository_UpdateCert_Call) Run(run func(ctx context.Context, domainID string, clientID string, clientCert string, clientKey string, caCert string)) *MockConfigRepository_UpdateCert_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string), args[4].(string), args[5].(string))
})
return _c
}
func (_c *MockConfigRepository_UpdateCert_Call) Return(config bootstrap.Config, err error) *MockConfigRepository_UpdateCert_Call {
_c.Call.Return(config, err)
return _c
}
func (_c *MockConfigRepository_UpdateCert_Call) RunAndReturn(run func(ctx context.Context, domainID string, clientID string, clientCert string, clientKey string, caCert string) (bootstrap.Config, error)) *MockConfigRepository_UpdateCert_Call {
_c.Call.Return(run)
return _c
}
// UpdateChannel provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) UpdateChannel(ctx context.Context, c bootstrap.Channel) error {
ret := _mock.Called(ctx, c)
if len(ret) == 0 {
panic("no return value specified for UpdateChannel")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, bootstrap.Channel) error); ok {
r0 = returnFunc(ctx, c)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_UpdateChannel_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateChannel'
type MockConfigRepository_UpdateChannel_Call struct {
*mock.Call
}
// UpdateChannel is a helper method to define mock.On call
// - ctx
// - c
func (_e *MockConfigRepository_Expecter) UpdateChannel(ctx interface{}, c interface{}) *MockConfigRepository_UpdateChannel_Call {
return &MockConfigRepository_UpdateChannel_Call{Call: _e.mock.On("UpdateChannel", ctx, c)}
}
func (_c *MockConfigRepository_UpdateChannel_Call) Run(run func(ctx context.Context, c bootstrap.Channel)) *MockConfigRepository_UpdateChannel_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(bootstrap.Channel))
})
return _c
}
func (_c *MockConfigRepository_UpdateChannel_Call) Return(err error) *MockConfigRepository_UpdateChannel_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_UpdateChannel_Call) RunAndReturn(run func(ctx context.Context, c bootstrap.Channel) error) *MockConfigRepository_UpdateChannel_Call {
_c.Call.Return(run)
return _c
}
// UpdateConnections provides a mock function for the type MockConfigRepository
func (_mock *MockConfigRepository) UpdateConnections(ctx context.Context, domainID string, id string, channels []bootstrap.Channel, connections []string) error {
ret := _mock.Called(ctx, domainID, id, channels, connections)
if len(ret) == 0 {
panic("no return value specified for UpdateConnections")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, []bootstrap.Channel, []string) error); ok {
r0 = returnFunc(ctx, domainID, id, channels, connections)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockConfigRepository_UpdateConnections_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateConnections'
type MockConfigRepository_UpdateConnections_Call struct {
*mock.Call
}
// UpdateConnections is a helper method to define mock.On call
// - ctx
// - domainID
// - id
// - channels
// - connections
func (_e *MockConfigRepository_Expecter) UpdateConnections(ctx interface{}, domainID interface{}, id interface{}, channels interface{}, connections interface{}) *MockConfigRepository_UpdateConnections_Call {
return &MockConfigRepository_UpdateConnections_Call{Call: _e.mock.On("UpdateConnections", ctx, domainID, id, channels, connections)}
}
func (_c *MockConfigRepository_UpdateConnections_Call) Run(run func(ctx context.Context, domainID string, id string, channels []bootstrap.Channel, connections []string)) *MockConfigRepository_UpdateConnections_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].([]bootstrap.Channel), args[4].([]string))
})
return _c
}
func (_c *MockConfigRepository_UpdateConnections_Call) Return(err error) *MockConfigRepository_UpdateConnections_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockConfigRepository_UpdateConnections_Call) RunAndReturn(run func(ctx context.Context, domainID string, id string, channels []bootstrap.Channel, connections []string) error) *MockConfigRepository_UpdateConnections_Call {
_c.Call.Return(run)
return _c
}
+547 -131
View File
@@ -1,26 +1,47 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
// Copyright (c) Abstract Machines
package mocks
package bootstrap
import (
bootstrap "github.com/absmach/magistrala/bootstrap"
authn "github.com/absmach/supermq/pkg/authn"
context "context"
"context"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/supermq/pkg/authn"
mock "github.com/stretchr/testify/mock"
)
// Service is an autogenerated mock type for the Service type
type Service struct {
// NewMockService creates a new instance of MockService. 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 NewMockService(t interface {
mock.TestingT
Cleanup(func())
}) *MockService {
mock := &MockService{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockService is an autogenerated mock type for the Service type
type MockService struct {
mock.Mock
}
// Add provides a mock function with given fields: ctx, session, token, cfg
func (_m *Service) Add(ctx context.Context, session authn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error) {
ret := _m.Called(ctx, session, token, cfg)
type MockService_Expecter struct {
mock *mock.Mock
}
func (_m *MockService) EXPECT() *MockService_Expecter {
return &MockService_Expecter{mock: &_m.Mock}
}
// Add provides a mock function for the type MockService
func (_mock *MockService) Add(ctx context.Context, session authn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error) {
ret := _mock.Called(ctx, session, token, cfg)
if len(ret) == 0 {
panic("no return value specified for Add")
@@ -28,27 +49,56 @@ func (_m *Service) Add(ctx context.Context, session authn.Session, token string,
var r0 bootstrap.Config
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, bootstrap.Config) (bootstrap.Config, error)); ok {
return rf(ctx, session, token, cfg)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string, bootstrap.Config) (bootstrap.Config, error)); ok {
return returnFunc(ctx, session, token, cfg)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, bootstrap.Config) bootstrap.Config); ok {
r0 = rf(ctx, session, token, cfg)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string, bootstrap.Config) bootstrap.Config); ok {
r0 = returnFunc(ctx, session, token, cfg)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, bootstrap.Config) error); ok {
r1 = rf(ctx, session, token, cfg)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, string, bootstrap.Config) error); ok {
r1 = returnFunc(ctx, session, token, cfg)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Bootstrap provides a mock function with given fields: ctx, externalKey, externalID, secure
func (_m *Service) Bootstrap(ctx context.Context, externalKey string, externalID string, secure bool) (bootstrap.Config, error) {
ret := _m.Called(ctx, externalKey, externalID, secure)
// MockService_Add_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Add'
type MockService_Add_Call struct {
*mock.Call
}
// Add is a helper method to define mock.On call
// - ctx
// - session
// - token
// - cfg
func (_e *MockService_Expecter) Add(ctx interface{}, session interface{}, token interface{}, cfg interface{}) *MockService_Add_Call {
return &MockService_Add_Call{Call: _e.mock.On("Add", ctx, session, token, cfg)}
}
func (_c *MockService_Add_Call) Run(run func(ctx context.Context, session authn.Session, token string, cfg bootstrap.Config)) *MockService_Add_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string), args[3].(bootstrap.Config))
})
return _c
}
func (_c *MockService_Add_Call) Return(config bootstrap.Config, err error) *MockService_Add_Call {
_c.Call.Return(config, err)
return _c
}
func (_c *MockService_Add_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error)) *MockService_Add_Call {
_c.Call.Return(run)
return _c
}
// Bootstrap provides a mock function for the type MockService
func (_mock *MockService) Bootstrap(ctx context.Context, externalKey string, externalID string, secure bool) (bootstrap.Config, error) {
ret := _mock.Called(ctx, externalKey, externalID, secure)
if len(ret) == 0 {
panic("no return value specified for Bootstrap")
@@ -56,81 +106,199 @@ func (_m *Service) Bootstrap(ctx context.Context, externalKey string, externalID
var r0 bootstrap.Config
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, string, bool) (bootstrap.Config, error)); ok {
return rf(ctx, externalKey, externalID, secure)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, bool) (bootstrap.Config, error)); ok {
return returnFunc(ctx, externalKey, externalID, secure)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string, bool) bootstrap.Config); ok {
r0 = rf(ctx, externalKey, externalID, secure)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string, bool) bootstrap.Config); ok {
r0 = returnFunc(ctx, externalKey, externalID, secure)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if rf, ok := ret.Get(1).(func(context.Context, string, string, bool) error); ok {
r1 = rf(ctx, externalKey, externalID, secure)
if returnFunc, ok := ret.Get(1).(func(context.Context, string, string, bool) error); ok {
r1 = returnFunc(ctx, externalKey, externalID, secure)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ChangeState provides a mock function with given fields: ctx, session, token, id, state
func (_m *Service) ChangeState(ctx context.Context, session authn.Session, token string, id string, state bootstrap.State) error {
ret := _m.Called(ctx, session, token, id, state)
// MockService_Bootstrap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Bootstrap'
type MockService_Bootstrap_Call struct {
*mock.Call
}
// Bootstrap is a helper method to define mock.On call
// - ctx
// - externalKey
// - externalID
// - secure
func (_e *MockService_Expecter) Bootstrap(ctx interface{}, externalKey interface{}, externalID interface{}, secure interface{}) *MockService_Bootstrap_Call {
return &MockService_Bootstrap_Call{Call: _e.mock.On("Bootstrap", ctx, externalKey, externalID, secure)}
}
func (_c *MockService_Bootstrap_Call) Run(run func(ctx context.Context, externalKey string, externalID string, secure bool)) *MockService_Bootstrap_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(bool))
})
return _c
}
func (_c *MockService_Bootstrap_Call) Return(config bootstrap.Config, err error) *MockService_Bootstrap_Call {
_c.Call.Return(config, err)
return _c
}
func (_c *MockService_Bootstrap_Call) RunAndReturn(run func(ctx context.Context, externalKey string, externalID string, secure bool) (bootstrap.Config, error)) *MockService_Bootstrap_Call {
_c.Call.Return(run)
return _c
}
// ChangeState provides a mock function for the type MockService
func (_mock *MockService) ChangeState(ctx context.Context, session authn.Session, token string, id string, state bootstrap.State) error {
ret := _mock.Called(ctx, session, token, id, state)
if len(ret) == 0 {
panic("no return value specified for ChangeState")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, bootstrap.State) error); ok {
r0 = rf(ctx, session, token, id, state)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, bootstrap.State) error); ok {
r0 = returnFunc(ctx, session, token, id, state)
} else {
r0 = ret.Error(0)
}
return r0
}
// ConnectClientHandler provides a mock function with given fields: ctx, channelID, clientID
func (_m *Service) ConnectClientHandler(ctx context.Context, channelID string, clientID string) error {
ret := _m.Called(ctx, channelID, clientID)
// MockService_ChangeState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ChangeState'
type MockService_ChangeState_Call struct {
*mock.Call
}
// ChangeState is a helper method to define mock.On call
// - ctx
// - session
// - token
// - id
// - state
func (_e *MockService_Expecter) ChangeState(ctx interface{}, session interface{}, token interface{}, id interface{}, state interface{}) *MockService_ChangeState_Call {
return &MockService_ChangeState_Call{Call: _e.mock.On("ChangeState", ctx, session, token, id, state)}
}
func (_c *MockService_ChangeState_Call) Run(run func(ctx context.Context, session authn.Session, token string, id string, state bootstrap.State)) *MockService_ChangeState_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string), args[3].(string), args[4].(bootstrap.State))
})
return _c
}
func (_c *MockService_ChangeState_Call) Return(err error) *MockService_ChangeState_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_ChangeState_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, token string, id string, state bootstrap.State) error) *MockService_ChangeState_Call {
_c.Call.Return(run)
return _c
}
// ConnectClientHandler provides a mock function for the type MockService
func (_mock *MockService) ConnectClientHandler(ctx context.Context, channelID string, clientID string) error {
ret := _mock.Called(ctx, channelID, clientID)
if len(ret) == 0 {
panic("no return value specified for ConnectClientHandler")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = rf(ctx, channelID, clientID)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = returnFunc(ctx, channelID, clientID)
} else {
r0 = ret.Error(0)
}
return r0
}
// DisconnectClientHandler provides a mock function with given fields: ctx, channelID, clientID
func (_m *Service) DisconnectClientHandler(ctx context.Context, channelID string, clientID string) error {
ret := _m.Called(ctx, channelID, clientID)
// MockService_ConnectClientHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConnectClientHandler'
type MockService_ConnectClientHandler_Call struct {
*mock.Call
}
// ConnectClientHandler is a helper method to define mock.On call
// - ctx
// - channelID
// - clientID
func (_e *MockService_Expecter) ConnectClientHandler(ctx interface{}, channelID interface{}, clientID interface{}) *MockService_ConnectClientHandler_Call {
return &MockService_ConnectClientHandler_Call{Call: _e.mock.On("ConnectClientHandler", ctx, channelID, clientID)}
}
func (_c *MockService_ConnectClientHandler_Call) Run(run func(ctx context.Context, channelID string, clientID string)) *MockService_ConnectClientHandler_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string))
})
return _c
}
func (_c *MockService_ConnectClientHandler_Call) Return(err error) *MockService_ConnectClientHandler_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_ConnectClientHandler_Call) RunAndReturn(run func(ctx context.Context, channelID string, clientID string) error) *MockService_ConnectClientHandler_Call {
_c.Call.Return(run)
return _c
}
// DisconnectClientHandler provides a mock function for the type MockService
func (_mock *MockService) DisconnectClientHandler(ctx context.Context, channelID string, clientID string) error {
ret := _mock.Called(ctx, channelID, clientID)
if len(ret) == 0 {
panic("no return value specified for DisconnectClientHandler")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = rf(ctx, channelID, clientID)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = returnFunc(ctx, channelID, clientID)
} else {
r0 = ret.Error(0)
}
return r0
}
// List provides a mock function with given fields: ctx, session, filter, offset, limit
func (_m *Service) List(ctx context.Context, session authn.Session, filter bootstrap.Filter, offset uint64, limit uint64) (bootstrap.ConfigsPage, error) {
ret := _m.Called(ctx, session, filter, offset, limit)
// MockService_DisconnectClientHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DisconnectClientHandler'
type MockService_DisconnectClientHandler_Call struct {
*mock.Call
}
// DisconnectClientHandler is a helper method to define mock.On call
// - ctx
// - channelID
// - clientID
func (_e *MockService_Expecter) DisconnectClientHandler(ctx interface{}, channelID interface{}, clientID interface{}) *MockService_DisconnectClientHandler_Call {
return &MockService_DisconnectClientHandler_Call{Call: _e.mock.On("DisconnectClientHandler", ctx, channelID, clientID)}
}
func (_c *MockService_DisconnectClientHandler_Call) Run(run func(ctx context.Context, channelID string, clientID string)) *MockService_DisconnectClientHandler_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string))
})
return _c
}
func (_c *MockService_DisconnectClientHandler_Call) Return(err error) *MockService_DisconnectClientHandler_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_DisconnectClientHandler_Call) RunAndReturn(run func(ctx context.Context, channelID string, clientID string) error) *MockService_DisconnectClientHandler_Call {
_c.Call.Return(run)
return _c
}
// List provides a mock function for the type MockService
func (_mock *MockService) List(ctx context.Context, session authn.Session, filter bootstrap.Filter, offset uint64, limit uint64) (bootstrap.ConfigsPage, error) {
ret := _mock.Called(ctx, session, filter, offset, limit)
if len(ret) == 0 {
panic("no return value specified for List")
@@ -138,99 +306,243 @@ func (_m *Service) List(ctx context.Context, session authn.Session, filter boots
var r0 bootstrap.ConfigsPage
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, bootstrap.Filter, uint64, uint64) (bootstrap.ConfigsPage, error)); ok {
return rf(ctx, session, filter, offset, limit)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, bootstrap.Filter, uint64, uint64) (bootstrap.ConfigsPage, error)); ok {
return returnFunc(ctx, session, filter, offset, limit)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, bootstrap.Filter, uint64, uint64) bootstrap.ConfigsPage); ok {
r0 = rf(ctx, session, filter, offset, limit)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, bootstrap.Filter, uint64, uint64) bootstrap.ConfigsPage); ok {
r0 = returnFunc(ctx, session, filter, offset, limit)
} else {
r0 = ret.Get(0).(bootstrap.ConfigsPage)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, bootstrap.Filter, uint64, uint64) error); ok {
r1 = rf(ctx, session, filter, offset, limit)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, bootstrap.Filter, uint64, uint64) error); ok {
r1 = returnFunc(ctx, session, filter, offset, limit)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Remove provides a mock function with given fields: ctx, session, id
func (_m *Service) Remove(ctx context.Context, session authn.Session, id string) error {
ret := _m.Called(ctx, session, id)
// MockService_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List'
type MockService_List_Call struct {
*mock.Call
}
// List is a helper method to define mock.On call
// - ctx
// - session
// - filter
// - offset
// - limit
func (_e *MockService_Expecter) List(ctx interface{}, session interface{}, filter interface{}, offset interface{}, limit interface{}) *MockService_List_Call {
return &MockService_List_Call{Call: _e.mock.On("List", ctx, session, filter, offset, limit)}
}
func (_c *MockService_List_Call) Run(run func(ctx context.Context, session authn.Session, filter bootstrap.Filter, offset uint64, limit uint64)) *MockService_List_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(bootstrap.Filter), args[3].(uint64), args[4].(uint64))
})
return _c
}
func (_c *MockService_List_Call) Return(configsPage bootstrap.ConfigsPage, err error) *MockService_List_Call {
_c.Call.Return(configsPage, err)
return _c
}
func (_c *MockService_List_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, filter bootstrap.Filter, offset uint64, limit uint64) (bootstrap.ConfigsPage, error)) *MockService_List_Call {
_c.Call.Return(run)
return _c
}
// Remove provides a mock function for the type MockService
func (_mock *MockService) Remove(ctx context.Context, session authn.Session, id string) error {
ret := _mock.Called(ctx, session, id)
if len(ret) == 0 {
panic("no return value specified for Remove")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) error); ok {
r0 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) error); ok {
r0 = returnFunc(ctx, session, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// RemoveChannelHandler provides a mock function with given fields: ctx, id
func (_m *Service) RemoveChannelHandler(ctx context.Context, id string) error {
ret := _m.Called(ctx, id)
// MockService_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove'
type MockService_Remove_Call struct {
*mock.Call
}
// Remove is a helper method to define mock.On call
// - ctx
// - session
// - id
func (_e *MockService_Expecter) Remove(ctx interface{}, session interface{}, id interface{}) *MockService_Remove_Call {
return &MockService_Remove_Call{Call: _e.mock.On("Remove", ctx, session, id)}
}
func (_c *MockService_Remove_Call) Run(run func(ctx context.Context, session authn.Session, id string)) *MockService_Remove_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string))
})
return _c
}
func (_c *MockService_Remove_Call) Return(err error) *MockService_Remove_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_Remove_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, id string) error) *MockService_Remove_Call {
_c.Call.Return(run)
return _c
}
// RemoveChannelHandler provides a mock function for the type MockService
func (_mock *MockService) RemoveChannelHandler(ctx context.Context, id string) error {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for RemoveChannelHandler")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(ctx, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// RemoveConfigHandler provides a mock function with given fields: ctx, id
func (_m *Service) RemoveConfigHandler(ctx context.Context, id string) error {
ret := _m.Called(ctx, id)
// MockService_RemoveChannelHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveChannelHandler'
type MockService_RemoveChannelHandler_Call struct {
*mock.Call
}
// RemoveChannelHandler is a helper method to define mock.On call
// - ctx
// - id
func (_e *MockService_Expecter) RemoveChannelHandler(ctx interface{}, id interface{}) *MockService_RemoveChannelHandler_Call {
return &MockService_RemoveChannelHandler_Call{Call: _e.mock.On("RemoveChannelHandler", ctx, id)}
}
func (_c *MockService_RemoveChannelHandler_Call) Run(run func(ctx context.Context, id string)) *MockService_RemoveChannelHandler_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockService_RemoveChannelHandler_Call) Return(err error) *MockService_RemoveChannelHandler_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_RemoveChannelHandler_Call) RunAndReturn(run func(ctx context.Context, id string) error) *MockService_RemoveChannelHandler_Call {
_c.Call.Return(run)
return _c
}
// RemoveConfigHandler provides a mock function for the type MockService
func (_mock *MockService) RemoveConfigHandler(ctx context.Context, id string) error {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for RemoveConfigHandler")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(ctx, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// Update provides a mock function with given fields: ctx, session, cfg
func (_m *Service) Update(ctx context.Context, session authn.Session, cfg bootstrap.Config) error {
ret := _m.Called(ctx, session, cfg)
// MockService_RemoveConfigHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveConfigHandler'
type MockService_RemoveConfigHandler_Call struct {
*mock.Call
}
// RemoveConfigHandler is a helper method to define mock.On call
// - ctx
// - id
func (_e *MockService_Expecter) RemoveConfigHandler(ctx interface{}, id interface{}) *MockService_RemoveConfigHandler_Call {
return &MockService_RemoveConfigHandler_Call{Call: _e.mock.On("RemoveConfigHandler", ctx, id)}
}
func (_c *MockService_RemoveConfigHandler_Call) Run(run func(ctx context.Context, id string)) *MockService_RemoveConfigHandler_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockService_RemoveConfigHandler_Call) Return(err error) *MockService_RemoveConfigHandler_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_RemoveConfigHandler_Call) RunAndReturn(run func(ctx context.Context, id string) error) *MockService_RemoveConfigHandler_Call {
_c.Call.Return(run)
return _c
}
// Update provides a mock function for the type MockService
func (_mock *MockService) Update(ctx context.Context, session authn.Session, cfg bootstrap.Config) error {
ret := _mock.Called(ctx, session, cfg)
if len(ret) == 0 {
panic("no return value specified for Update")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, bootstrap.Config) error); ok {
r0 = rf(ctx, session, cfg)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, bootstrap.Config) error); ok {
r0 = returnFunc(ctx, session, cfg)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateCert provides a mock function with given fields: ctx, session, clientID, clientCert, clientKey, caCert
func (_m *Service) UpdateCert(ctx context.Context, session authn.Session, clientID string, clientCert string, clientKey string, caCert string) (bootstrap.Config, error) {
ret := _m.Called(ctx, session, clientID, clientCert, clientKey, caCert)
// MockService_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update'
type MockService_Update_Call struct {
*mock.Call
}
// Update is a helper method to define mock.On call
// - ctx
// - session
// - cfg
func (_e *MockService_Expecter) Update(ctx interface{}, session interface{}, cfg interface{}) *MockService_Update_Call {
return &MockService_Update_Call{Call: _e.mock.On("Update", ctx, session, cfg)}
}
func (_c *MockService_Update_Call) Run(run func(ctx context.Context, session authn.Session, cfg bootstrap.Config)) *MockService_Update_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(bootstrap.Config))
})
return _c
}
func (_c *MockService_Update_Call) Return(err error) *MockService_Update_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_Update_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, cfg bootstrap.Config) error) *MockService_Update_Call {
_c.Call.Return(run)
return _c
}
// UpdateCert provides a mock function for the type MockService
func (_mock *MockService) UpdateCert(ctx context.Context, session authn.Session, clientID string, clientCert string, clientKey string, caCert string) (bootstrap.Config, error) {
ret := _mock.Called(ctx, session, clientID, clientCert, clientKey, caCert)
if len(ret) == 0 {
panic("no return value specified for UpdateCert")
@@ -238,63 +550,153 @@ func (_m *Service) UpdateCert(ctx context.Context, session authn.Session, client
var r0 bootstrap.Config
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string, string) (bootstrap.Config, error)); ok {
return rf(ctx, session, clientID, clientCert, clientKey, caCert)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string, string) (bootstrap.Config, error)); ok {
return returnFunc(ctx, session, clientID, clientCert, clientKey, caCert)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string, string) bootstrap.Config); ok {
r0 = rf(ctx, session, clientID, clientCert, clientKey, caCert)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, string, string) bootstrap.Config); ok {
r0 = returnFunc(ctx, session, clientID, clientCert, clientKey, caCert)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, string, string) error); ok {
r1 = rf(ctx, session, clientID, clientCert, clientKey, caCert)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, string, string, string, string) error); ok {
r1 = returnFunc(ctx, session, clientID, clientCert, clientKey, caCert)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UpdateChannelHandler provides a mock function with given fields: ctx, channel
func (_m *Service) UpdateChannelHandler(ctx context.Context, channel bootstrap.Channel) error {
ret := _m.Called(ctx, channel)
// MockService_UpdateCert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateCert'
type MockService_UpdateCert_Call struct {
*mock.Call
}
// UpdateCert is a helper method to define mock.On call
// - ctx
// - session
// - clientID
// - clientCert
// - clientKey
// - caCert
func (_e *MockService_Expecter) UpdateCert(ctx interface{}, session interface{}, clientID interface{}, clientCert interface{}, clientKey interface{}, caCert interface{}) *MockService_UpdateCert_Call {
return &MockService_UpdateCert_Call{Call: _e.mock.On("UpdateCert", ctx, session, clientID, clientCert, clientKey, caCert)}
}
func (_c *MockService_UpdateCert_Call) Run(run func(ctx context.Context, session authn.Session, clientID string, clientCert string, clientKey string, caCert string)) *MockService_UpdateCert_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string), args[3].(string), args[4].(string), args[5].(string))
})
return _c
}
func (_c *MockService_UpdateCert_Call) Return(config bootstrap.Config, err error) *MockService_UpdateCert_Call {
_c.Call.Return(config, err)
return _c
}
func (_c *MockService_UpdateCert_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, clientID string, clientCert string, clientKey string, caCert string) (bootstrap.Config, error)) *MockService_UpdateCert_Call {
_c.Call.Return(run)
return _c
}
// UpdateChannelHandler provides a mock function for the type MockService
func (_mock *MockService) UpdateChannelHandler(ctx context.Context, channel bootstrap.Channel) error {
ret := _mock.Called(ctx, channel)
if len(ret) == 0 {
panic("no return value specified for UpdateChannelHandler")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, bootstrap.Channel) error); ok {
r0 = rf(ctx, channel)
if returnFunc, ok := ret.Get(0).(func(context.Context, bootstrap.Channel) error); ok {
r0 = returnFunc(ctx, channel)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateConnections provides a mock function with given fields: ctx, session, token, id, connections
func (_m *Service) UpdateConnections(ctx context.Context, session authn.Session, token string, id string, connections []string) error {
ret := _m.Called(ctx, session, token, id, connections)
// MockService_UpdateChannelHandler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateChannelHandler'
type MockService_UpdateChannelHandler_Call struct {
*mock.Call
}
// UpdateChannelHandler is a helper method to define mock.On call
// - ctx
// - channel
func (_e *MockService_Expecter) UpdateChannelHandler(ctx interface{}, channel interface{}) *MockService_UpdateChannelHandler_Call {
return &MockService_UpdateChannelHandler_Call{Call: _e.mock.On("UpdateChannelHandler", ctx, channel)}
}
func (_c *MockService_UpdateChannelHandler_Call) Run(run func(ctx context.Context, channel bootstrap.Channel)) *MockService_UpdateChannelHandler_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(bootstrap.Channel))
})
return _c
}
func (_c *MockService_UpdateChannelHandler_Call) Return(err error) *MockService_UpdateChannelHandler_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_UpdateChannelHandler_Call) RunAndReturn(run func(ctx context.Context, channel bootstrap.Channel) error) *MockService_UpdateChannelHandler_Call {
_c.Call.Return(run)
return _c
}
// UpdateConnections provides a mock function for the type MockService
func (_mock *MockService) UpdateConnections(ctx context.Context, session authn.Session, token string, id string, connections []string) error {
ret := _mock.Called(ctx, session, token, id, connections)
if len(ret) == 0 {
panic("no return value specified for UpdateConnections")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok {
r0 = rf(ctx, session, token, id, connections)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string, string, []string) error); ok {
r0 = returnFunc(ctx, session, token, id, connections)
} else {
r0 = ret.Error(0)
}
return r0
}
// View provides a mock function with given fields: ctx, session, id
func (_m *Service) View(ctx context.Context, session authn.Session, id string) (bootstrap.Config, error) {
ret := _m.Called(ctx, session, id)
// MockService_UpdateConnections_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateConnections'
type MockService_UpdateConnections_Call struct {
*mock.Call
}
// UpdateConnections is a helper method to define mock.On call
// - ctx
// - session
// - token
// - id
// - connections
func (_e *MockService_Expecter) UpdateConnections(ctx interface{}, session interface{}, token interface{}, id interface{}, connections interface{}) *MockService_UpdateConnections_Call {
return &MockService_UpdateConnections_Call{Call: _e.mock.On("UpdateConnections", ctx, session, token, id, connections)}
}
func (_c *MockService_UpdateConnections_Call) Run(run func(ctx context.Context, session authn.Session, token string, id string, connections []string)) *MockService_UpdateConnections_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string), args[3].(string), args[4].([]string))
})
return _c
}
func (_c *MockService_UpdateConnections_Call) Return(err error) *MockService_UpdateConnections_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_UpdateConnections_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, token string, id string, connections []string) error) *MockService_UpdateConnections_Call {
_c.Call.Return(run)
return _c
}
// View provides a mock function for the type MockService
func (_mock *MockService) View(ctx context.Context, session authn.Session, id string) (bootstrap.Config, error) {
ret := _mock.Called(ctx, session, id)
if len(ret) == 0 {
panic("no return value specified for View")
@@ -302,34 +704,48 @@ func (_m *Service) View(ctx context.Context, session authn.Session, id string) (
var r0 bootstrap.Config
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) (bootstrap.Config, error)); ok {
return rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) (bootstrap.Config, error)); ok {
return returnFunc(ctx, session, id)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) bootstrap.Config); ok {
r0 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) bootstrap.Config); ok {
r0 = returnFunc(ctx, session, id)
} else {
r0 = ret.Get(0).(bootstrap.Config)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string) error); ok {
r1 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, string) error); ok {
r1 = returnFunc(ctx, session, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// 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
// MockService_View_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'View'
type MockService_View_Call struct {
*mock.Call
}
// View is a helper method to define mock.On call
// - ctx
// - session
// - id
func (_e *MockService_Expecter) View(ctx interface{}, session interface{}, id interface{}) *MockService_View_Call {
return &MockService_View_Call{Call: _e.mock.On("View", ctx, session, id)}
}
func (_c *MockService_View_Call) Run(run func(ctx context.Context, session authn.Session, id string)) *MockService_View_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string))
})
return _c
}
func (_c *MockService_View_Call) Return(config bootstrap.Config, err error) *MockService_View_Call {
_c.Call.Return(config, err)
return _c
}
func (_c *MockService_View_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, id string) (bootstrap.Config, error)) *MockService_View_Call {
_c.Call.Return(run)
return _c
}
-4
View File
@@ -60,8 +60,6 @@ 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 Client Config to the user identified by the provided token.
Add(ctx context.Context, session smqauthn.Session, token string, cfg Config) (Config, error)
@@ -115,8 +113,6 @@ type Service interface {
// as a JSON and consumed from the client side. The purpose of this interface
// is to provide convenient way to generate custom configuration response
// based on the specific Config which will be consumed by the client.
//
//go:generate mockery --name ConfigReader --output=./mocks --filename config_reader.go --quiet --note "Copyright (c) Abstract Machines"
type ConfigReader interface {
ReadConfig(Config, bool) (interface{}, error)
}
+3 -3
View File
@@ -15,7 +15,7 @@ import (
"testing"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/bootstrap/mocks"
mocks "github.com/absmach/magistrala/bootstrap/mocks"
"github.com/absmach/magistrala/internal/testsutil"
smqauthn "github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/errors"
@@ -60,13 +60,13 @@ var (
)
var (
boot *mocks.ConfigRepository
boot *mocks.MockConfigRepository
policies *policymocks.Service
sdk *sdkmocks.SDK
)
func newService() bootstrap.Service {
boot = new(mocks.ConfigRepository)
boot = new(mocks.MockConfigRepository)
policies = new(policymocks.Service)
sdk = new(sdkmocks.SDK)
idp := uuid.NewMock()
+1 -1
View File
@@ -13,6 +13,6 @@ For an in-depth explanation of the usage of `consumers`, as well as thorough
understanding of SuperMQ, please check out the [official documentation][doc].
For more information about service capabilities and its usage, please check out
the [API documentation](https://docs.api.supermq.abstractmachines.fr/?urls.primaryName=consumers-notifiers-openapi.yml).
the [API documentation](https://docs.api.supermq.abstractmachines.fr/?urls.primaryName=consumers-notifiers-openapi.yaml).
[doc]: https://docs.supermq.abstractmachines.fr
+3 -3
View File
@@ -15,7 +15,7 @@ import (
"github.com/absmach/magistrala/consumers/notifiers"
"github.com/absmach/magistrala/consumers/notifiers/api"
"github.com/absmach/magistrala/consumers/notifiers/mocks"
mocks "github.com/absmach/magistrala/consumers/notifiers/mocks"
"github.com/absmach/magistrala/internal/testsutil"
apiutil "github.com/absmach/supermq/api/http/util"
smqlog "github.com/absmach/supermq/logger"
@@ -67,9 +67,9 @@ func (tr testRequest) make() (*http.Response, error) {
return tr.client.Do(req)
}
func newServer() (*httptest.Server, *mocks.Service) {
func newServer() (*httptest.Server, *mocks.MockService) {
logger := smqlog.NewMock()
svc := new(mocks.Service)
svc := new(mocks.MockService)
mux := api.MakeHandler(svc, logger, instanceID)
return httptest.NewServer(mux), svc
}
-5
View File
@@ -1,5 +0,0 @@
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0
// Package mocks contains mocks for testing purposes.
package mocks
+176 -59
View File
@@ -1,42 +1,92 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
// Copyright (c) Abstract Machines
package mocks
package notifiers
import (
context "context"
"context"
notifiers "github.com/absmach/magistrala/consumers/notifiers"
"github.com/absmach/magistrala/consumers/notifiers"
mock "github.com/stretchr/testify/mock"
)
// SubscriptionsRepository is an autogenerated mock type for the SubscriptionsRepository type
type SubscriptionsRepository struct {
// NewMockSubscriptionsRepository creates a new instance of MockSubscriptionsRepository. 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 NewMockSubscriptionsRepository(t interface {
mock.TestingT
Cleanup(func())
}) *MockSubscriptionsRepository {
mock := &MockSubscriptionsRepository{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockSubscriptionsRepository is an autogenerated mock type for the SubscriptionsRepository type
type MockSubscriptionsRepository struct {
mock.Mock
}
// Remove provides a mock function with given fields: ctx, id
func (_m *SubscriptionsRepository) Remove(ctx context.Context, id string) error {
ret := _m.Called(ctx, id)
type MockSubscriptionsRepository_Expecter struct {
mock *mock.Mock
}
func (_m *MockSubscriptionsRepository) EXPECT() *MockSubscriptionsRepository_Expecter {
return &MockSubscriptionsRepository_Expecter{mock: &_m.Mock}
}
// Remove provides a mock function for the type MockSubscriptionsRepository
func (_mock *MockSubscriptionsRepository) Remove(ctx context.Context, id string) error {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for Remove")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(ctx, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// Retrieve provides a mock function with given fields: ctx, id
func (_m *SubscriptionsRepository) Retrieve(ctx context.Context, id string) (notifiers.Subscription, error) {
ret := _m.Called(ctx, id)
// MockSubscriptionsRepository_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove'
type MockSubscriptionsRepository_Remove_Call struct {
*mock.Call
}
// Remove is a helper method to define mock.On call
// - ctx
// - id
func (_e *MockSubscriptionsRepository_Expecter) Remove(ctx interface{}, id interface{}) *MockSubscriptionsRepository_Remove_Call {
return &MockSubscriptionsRepository_Remove_Call{Call: _e.mock.On("Remove", ctx, id)}
}
func (_c *MockSubscriptionsRepository_Remove_Call) Run(run func(ctx context.Context, id string)) *MockSubscriptionsRepository_Remove_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockSubscriptionsRepository_Remove_Call) Return(err error) *MockSubscriptionsRepository_Remove_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockSubscriptionsRepository_Remove_Call) RunAndReturn(run func(ctx context.Context, id string) error) *MockSubscriptionsRepository_Remove_Call {
_c.Call.Return(run)
return _c
}
// Retrieve provides a mock function for the type MockSubscriptionsRepository
func (_mock *MockSubscriptionsRepository) Retrieve(ctx context.Context, id string) (notifiers.Subscription, error) {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for Retrieve")
@@ -44,27 +94,54 @@ func (_m *SubscriptionsRepository) Retrieve(ctx context.Context, id string) (not
var r0 notifiers.Subscription
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string) (notifiers.Subscription, error)); ok {
return rf(ctx, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, string) (notifiers.Subscription, error)); ok {
return returnFunc(ctx, id)
}
if rf, ok := ret.Get(0).(func(context.Context, string) notifiers.Subscription); ok {
r0 = rf(ctx, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, string) notifiers.Subscription); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Get(0).(notifiers.Subscription)
}
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
r1 = rf(ctx, id)
if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
r1 = returnFunc(ctx, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// RetrieveAll provides a mock function with given fields: ctx, pm
func (_m *SubscriptionsRepository) RetrieveAll(ctx context.Context, pm notifiers.PageMetadata) (notifiers.Page, error) {
ret := _m.Called(ctx, pm)
// MockSubscriptionsRepository_Retrieve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Retrieve'
type MockSubscriptionsRepository_Retrieve_Call struct {
*mock.Call
}
// Retrieve is a helper method to define mock.On call
// - ctx
// - id
func (_e *MockSubscriptionsRepository_Expecter) Retrieve(ctx interface{}, id interface{}) *MockSubscriptionsRepository_Retrieve_Call {
return &MockSubscriptionsRepository_Retrieve_Call{Call: _e.mock.On("Retrieve", ctx, id)}
}
func (_c *MockSubscriptionsRepository_Retrieve_Call) Run(run func(ctx context.Context, id string)) *MockSubscriptionsRepository_Retrieve_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockSubscriptionsRepository_Retrieve_Call) Return(subscription notifiers.Subscription, err error) *MockSubscriptionsRepository_Retrieve_Call {
_c.Call.Return(subscription, err)
return _c
}
func (_c *MockSubscriptionsRepository_Retrieve_Call) RunAndReturn(run func(ctx context.Context, id string) (notifiers.Subscription, error)) *MockSubscriptionsRepository_Retrieve_Call {
_c.Call.Return(run)
return _c
}
// RetrieveAll provides a mock function for the type MockSubscriptionsRepository
func (_mock *MockSubscriptionsRepository) RetrieveAll(ctx context.Context, pm notifiers.PageMetadata) (notifiers.Page, error) {
ret := _mock.Called(ctx, pm)
if len(ret) == 0 {
panic("no return value specified for RetrieveAll")
@@ -72,27 +149,54 @@ func (_m *SubscriptionsRepository) RetrieveAll(ctx context.Context, pm notifiers
var r0 notifiers.Page
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, notifiers.PageMetadata) (notifiers.Page, error)); ok {
return rf(ctx, pm)
if returnFunc, ok := ret.Get(0).(func(context.Context, notifiers.PageMetadata) (notifiers.Page, error)); ok {
return returnFunc(ctx, pm)
}
if rf, ok := ret.Get(0).(func(context.Context, notifiers.PageMetadata) notifiers.Page); ok {
r0 = rf(ctx, pm)
if returnFunc, ok := ret.Get(0).(func(context.Context, notifiers.PageMetadata) notifiers.Page); ok {
r0 = returnFunc(ctx, pm)
} else {
r0 = ret.Get(0).(notifiers.Page)
}
if rf, ok := ret.Get(1).(func(context.Context, notifiers.PageMetadata) error); ok {
r1 = rf(ctx, pm)
if returnFunc, ok := ret.Get(1).(func(context.Context, notifiers.PageMetadata) error); ok {
r1 = returnFunc(ctx, pm)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Save provides a mock function with given fields: ctx, sub
func (_m *SubscriptionsRepository) Save(ctx context.Context, sub notifiers.Subscription) (string, error) {
ret := _m.Called(ctx, sub)
// MockSubscriptionsRepository_RetrieveAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RetrieveAll'
type MockSubscriptionsRepository_RetrieveAll_Call struct {
*mock.Call
}
// RetrieveAll is a helper method to define mock.On call
// - ctx
// - pm
func (_e *MockSubscriptionsRepository_Expecter) RetrieveAll(ctx interface{}, pm interface{}) *MockSubscriptionsRepository_RetrieveAll_Call {
return &MockSubscriptionsRepository_RetrieveAll_Call{Call: _e.mock.On("RetrieveAll", ctx, pm)}
}
func (_c *MockSubscriptionsRepository_RetrieveAll_Call) Run(run func(ctx context.Context, pm notifiers.PageMetadata)) *MockSubscriptionsRepository_RetrieveAll_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(notifiers.PageMetadata))
})
return _c
}
func (_c *MockSubscriptionsRepository_RetrieveAll_Call) Return(page notifiers.Page, err error) *MockSubscriptionsRepository_RetrieveAll_Call {
_c.Call.Return(page, err)
return _c
}
func (_c *MockSubscriptionsRepository_RetrieveAll_Call) RunAndReturn(run func(ctx context.Context, pm notifiers.PageMetadata) (notifiers.Page, error)) *MockSubscriptionsRepository_RetrieveAll_Call {
_c.Call.Return(run)
return _c
}
// Save provides a mock function for the type MockSubscriptionsRepository
func (_mock *MockSubscriptionsRepository) Save(ctx context.Context, sub notifiers.Subscription) (string, error) {
ret := _mock.Called(ctx, sub)
if len(ret) == 0 {
panic("no return value specified for Save")
@@ -100,34 +204,47 @@ func (_m *SubscriptionsRepository) Save(ctx context.Context, sub notifiers.Subsc
var r0 string
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, notifiers.Subscription) (string, error)); ok {
return rf(ctx, sub)
if returnFunc, ok := ret.Get(0).(func(context.Context, notifiers.Subscription) (string, error)); ok {
return returnFunc(ctx, sub)
}
if rf, ok := ret.Get(0).(func(context.Context, notifiers.Subscription) string); ok {
r0 = rf(ctx, sub)
if returnFunc, ok := ret.Get(0).(func(context.Context, notifiers.Subscription) string); ok {
r0 = returnFunc(ctx, sub)
} else {
r0 = ret.Get(0).(string)
}
if rf, ok := ret.Get(1).(func(context.Context, notifiers.Subscription) error); ok {
r1 = rf(ctx, sub)
if returnFunc, ok := ret.Get(1).(func(context.Context, notifiers.Subscription) error); ok {
r1 = returnFunc(ctx, sub)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// NewSubscriptionsRepository creates a new instance of SubscriptionsRepository. 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 NewSubscriptionsRepository(t interface {
mock.TestingT
Cleanup(func())
}) *SubscriptionsRepository {
mock := &SubscriptionsRepository{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
// MockSubscriptionsRepository_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save'
type MockSubscriptionsRepository_Save_Call struct {
*mock.Call
}
// Save is a helper method to define mock.On call
// - ctx
// - sub
func (_e *MockSubscriptionsRepository_Expecter) Save(ctx interface{}, sub interface{}) *MockSubscriptionsRepository_Save_Call {
return &MockSubscriptionsRepository_Save_Call{Call: _e.mock.On("Save", ctx, sub)}
}
func (_c *MockSubscriptionsRepository_Save_Call) Run(run func(ctx context.Context, sub notifiers.Subscription)) *MockSubscriptionsRepository_Save_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(notifiers.Subscription))
})
return _c
}
func (_c *MockSubscriptionsRepository_Save_Call) Return(s string, err error) *MockSubscriptionsRepository_Save_Call {
_c.Call.Return(s, err)
return _c
}
func (_c *MockSubscriptionsRepository_Save_Call) RunAndReturn(run func(ctx context.Context, sub notifiers.Subscription) (string, error)) *MockSubscriptionsRepository_Save_Call {
_c.Call.Return(run)
return _c
}
+214 -65
View File
@@ -1,42 +1,92 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
// Copyright (c) Abstract Machines
package mocks
package notifiers
import (
context "context"
"context"
notifiers "github.com/absmach/magistrala/consumers/notifiers"
"github.com/absmach/magistrala/consumers/notifiers"
mock "github.com/stretchr/testify/mock"
)
// Service is an autogenerated mock type for the Service type
type Service struct {
// NewMockService creates a new instance of MockService. 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 NewMockService(t interface {
mock.TestingT
Cleanup(func())
}) *MockService {
mock := &MockService{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockService is an autogenerated mock type for the Service type
type MockService struct {
mock.Mock
}
// ConsumeBlocking provides a mock function with given fields: ctx, messages
func (_m *Service) ConsumeBlocking(ctx context.Context, messages interface{}) error {
ret := _m.Called(ctx, messages)
type MockService_Expecter struct {
mock *mock.Mock
}
func (_m *MockService) EXPECT() *MockService_Expecter {
return &MockService_Expecter{mock: &_m.Mock}
}
// ConsumeBlocking provides a mock function for the type MockService
func (_mock *MockService) ConsumeBlocking(ctx context.Context, messages interface{}) error {
ret := _mock.Called(ctx, messages)
if len(ret) == 0 {
panic("no return value specified for ConsumeBlocking")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok {
r0 = rf(ctx, messages)
if returnFunc, ok := ret.Get(0).(func(context.Context, interface{}) error); ok {
r0 = returnFunc(ctx, messages)
} else {
r0 = ret.Error(0)
}
return r0
}
// CreateSubscription provides a mock function with given fields: ctx, token, sub
func (_m *Service) CreateSubscription(ctx context.Context, token string, sub notifiers.Subscription) (string, error) {
ret := _m.Called(ctx, token, sub)
// MockService_ConsumeBlocking_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConsumeBlocking'
type MockService_ConsumeBlocking_Call struct {
*mock.Call
}
// ConsumeBlocking is a helper method to define mock.On call
// - ctx
// - messages
func (_e *MockService_Expecter) ConsumeBlocking(ctx interface{}, messages interface{}) *MockService_ConsumeBlocking_Call {
return &MockService_ConsumeBlocking_Call{Call: _e.mock.On("ConsumeBlocking", ctx, messages)}
}
func (_c *MockService_ConsumeBlocking_Call) Run(run func(ctx context.Context, messages interface{})) *MockService_ConsumeBlocking_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(interface{}))
})
return _c
}
func (_c *MockService_ConsumeBlocking_Call) Return(err error) *MockService_ConsumeBlocking_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_ConsumeBlocking_Call) RunAndReturn(run func(ctx context.Context, messages interface{}) error) *MockService_ConsumeBlocking_Call {
_c.Call.Return(run)
return _c
}
// CreateSubscription provides a mock function for the type MockService
func (_mock *MockService) CreateSubscription(ctx context.Context, token string, sub notifiers.Subscription) (string, error) {
ret := _mock.Called(ctx, token, sub)
if len(ret) == 0 {
panic("no return value specified for CreateSubscription")
@@ -44,27 +94,55 @@ func (_m *Service) CreateSubscription(ctx context.Context, token string, sub not
var r0 string
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, notifiers.Subscription) (string, error)); ok {
return rf(ctx, token, sub)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, notifiers.Subscription) (string, error)); ok {
return returnFunc(ctx, token, sub)
}
if rf, ok := ret.Get(0).(func(context.Context, string, notifiers.Subscription) string); ok {
r0 = rf(ctx, token, sub)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, notifiers.Subscription) string); ok {
r0 = returnFunc(ctx, token, sub)
} else {
r0 = ret.Get(0).(string)
}
if rf, ok := ret.Get(1).(func(context.Context, string, notifiers.Subscription) error); ok {
r1 = rf(ctx, token, sub)
if returnFunc, ok := ret.Get(1).(func(context.Context, string, notifiers.Subscription) error); ok {
r1 = returnFunc(ctx, token, sub)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ListSubscriptions provides a mock function with given fields: ctx, token, pm
func (_m *Service) ListSubscriptions(ctx context.Context, token string, pm notifiers.PageMetadata) (notifiers.Page, error) {
ret := _m.Called(ctx, token, pm)
// MockService_CreateSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSubscription'
type MockService_CreateSubscription_Call struct {
*mock.Call
}
// CreateSubscription is a helper method to define mock.On call
// - ctx
// - token
// - sub
func (_e *MockService_Expecter) CreateSubscription(ctx interface{}, token interface{}, sub interface{}) *MockService_CreateSubscription_Call {
return &MockService_CreateSubscription_Call{Call: _e.mock.On("CreateSubscription", ctx, token, sub)}
}
func (_c *MockService_CreateSubscription_Call) Run(run func(ctx context.Context, token string, sub notifiers.Subscription)) *MockService_CreateSubscription_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(notifiers.Subscription))
})
return _c
}
func (_c *MockService_CreateSubscription_Call) Return(s string, err error) *MockService_CreateSubscription_Call {
_c.Call.Return(s, err)
return _c
}
func (_c *MockService_CreateSubscription_Call) RunAndReturn(run func(ctx context.Context, token string, sub notifiers.Subscription) (string, error)) *MockService_CreateSubscription_Call {
_c.Call.Return(run)
return _c
}
// ListSubscriptions provides a mock function for the type MockService
func (_mock *MockService) ListSubscriptions(ctx context.Context, token string, pm notifiers.PageMetadata) (notifiers.Page, error) {
ret := _mock.Called(ctx, token, pm)
if len(ret) == 0 {
panic("no return value specified for ListSubscriptions")
@@ -72,45 +150,102 @@ func (_m *Service) ListSubscriptions(ctx context.Context, token string, pm notif
var r0 notifiers.Page
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, notifiers.PageMetadata) (notifiers.Page, error)); ok {
return rf(ctx, token, pm)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, notifiers.PageMetadata) (notifiers.Page, error)); ok {
return returnFunc(ctx, token, pm)
}
if rf, ok := ret.Get(0).(func(context.Context, string, notifiers.PageMetadata) notifiers.Page); ok {
r0 = rf(ctx, token, pm)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, notifiers.PageMetadata) notifiers.Page); ok {
r0 = returnFunc(ctx, token, pm)
} else {
r0 = ret.Get(0).(notifiers.Page)
}
if rf, ok := ret.Get(1).(func(context.Context, string, notifiers.PageMetadata) error); ok {
r1 = rf(ctx, token, pm)
if returnFunc, ok := ret.Get(1).(func(context.Context, string, notifiers.PageMetadata) error); ok {
r1 = returnFunc(ctx, token, pm)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// RemoveSubscription provides a mock function with given fields: ctx, token, id
func (_m *Service) RemoveSubscription(ctx context.Context, token string, id string) error {
ret := _m.Called(ctx, token, id)
// MockService_ListSubscriptions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSubscriptions'
type MockService_ListSubscriptions_Call struct {
*mock.Call
}
// ListSubscriptions is a helper method to define mock.On call
// - ctx
// - token
// - pm
func (_e *MockService_Expecter) ListSubscriptions(ctx interface{}, token interface{}, pm interface{}) *MockService_ListSubscriptions_Call {
return &MockService_ListSubscriptions_Call{Call: _e.mock.On("ListSubscriptions", ctx, token, pm)}
}
func (_c *MockService_ListSubscriptions_Call) Run(run func(ctx context.Context, token string, pm notifiers.PageMetadata)) *MockService_ListSubscriptions_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(notifiers.PageMetadata))
})
return _c
}
func (_c *MockService_ListSubscriptions_Call) Return(page notifiers.Page, err error) *MockService_ListSubscriptions_Call {
_c.Call.Return(page, err)
return _c
}
func (_c *MockService_ListSubscriptions_Call) RunAndReturn(run func(ctx context.Context, token string, pm notifiers.PageMetadata) (notifiers.Page, error)) *MockService_ListSubscriptions_Call {
_c.Call.Return(run)
return _c
}
// RemoveSubscription provides a mock function for the type MockService
func (_mock *MockService) RemoveSubscription(ctx context.Context, token string, id string) error {
ret := _mock.Called(ctx, token, id)
if len(ret) == 0 {
panic("no return value specified for RemoveSubscription")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = rf(ctx, token, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) error); ok {
r0 = returnFunc(ctx, token, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// ViewSubscription provides a mock function with given fields: ctx, token, id
func (_m *Service) ViewSubscription(ctx context.Context, token string, id string) (notifiers.Subscription, error) {
ret := _m.Called(ctx, token, id)
// MockService_RemoveSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveSubscription'
type MockService_RemoveSubscription_Call struct {
*mock.Call
}
// RemoveSubscription is a helper method to define mock.On call
// - ctx
// - token
// - id
func (_e *MockService_Expecter) RemoveSubscription(ctx interface{}, token interface{}, id interface{}) *MockService_RemoveSubscription_Call {
return &MockService_RemoveSubscription_Call{Call: _e.mock.On("RemoveSubscription", ctx, token, id)}
}
func (_c *MockService_RemoveSubscription_Call) Run(run func(ctx context.Context, token string, id string)) *MockService_RemoveSubscription_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string))
})
return _c
}
func (_c *MockService_RemoveSubscription_Call) Return(err error) *MockService_RemoveSubscription_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_RemoveSubscription_Call) RunAndReturn(run func(ctx context.Context, token string, id string) error) *MockService_RemoveSubscription_Call {
_c.Call.Return(run)
return _c
}
// ViewSubscription provides a mock function for the type MockService
func (_mock *MockService) ViewSubscription(ctx context.Context, token string, id string) (notifiers.Subscription, error) {
ret := _mock.Called(ctx, token, id)
if len(ret) == 0 {
panic("no return value specified for ViewSubscription")
@@ -118,34 +253,48 @@ func (_m *Service) ViewSubscription(ctx context.Context, token string, id string
var r0 notifiers.Subscription
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, string) (notifiers.Subscription, error)); ok {
return rf(ctx, token, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) (notifiers.Subscription, error)); ok {
return returnFunc(ctx, token, id)
}
if rf, ok := ret.Get(0).(func(context.Context, string, string) notifiers.Subscription); ok {
r0 = rf(ctx, token, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, string, string) notifiers.Subscription); ok {
r0 = returnFunc(ctx, token, id)
} else {
r0 = ret.Get(0).(notifiers.Subscription)
}
if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
r1 = rf(ctx, token, id)
if returnFunc, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
r1 = returnFunc(ctx, token, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// 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
// MockService_ViewSubscription_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ViewSubscription'
type MockService_ViewSubscription_Call struct {
*mock.Call
}
// ViewSubscription is a helper method to define mock.On call
// - ctx
// - token
// - id
func (_e *MockService_Expecter) ViewSubscription(ctx interface{}, token interface{}, id interface{}) *MockService_ViewSubscription_Call {
return &MockService_ViewSubscription_Call{Call: _e.mock.On("ViewSubscription", ctx, token, id)}
}
func (_c *MockService_ViewSubscription_Call) Run(run func(ctx context.Context, token string, id string)) *MockService_ViewSubscription_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(string))
})
return _c
}
func (_c *MockService_ViewSubscription_Call) Return(subscription notifiers.Subscription, err error) *MockService_ViewSubscription_Call {
_c.Call.Return(subscription, err)
return _c
}
func (_c *MockService_ViewSubscription_Call) RunAndReturn(run func(ctx context.Context, token string, id string) (notifiers.Subscription, error)) *MockService_ViewSubscription_Call {
_c.Call.Return(run)
return _c
}
-2
View File
@@ -21,8 +21,6 @@ var ErrMessage = errors.New("failed to convert to SuperMQ message")
var _ consumers.AsyncConsumer = (*notifierService)(nil)
// Service reprents a notification service.
//
//go:generate mockery --name Service --output=./mocks --filename service.go --quiet --note "Copyright (c) Abstract Machines"
type Service interface {
// CreateSubscription persists a subscription.
// Successful operation is indicated by non-nil error response.
+3 -3
View File
@@ -9,7 +9,7 @@ import (
"testing"
"github.com/absmach/magistrala/consumers/notifiers"
"github.com/absmach/magistrala/consumers/notifiers/mocks"
mocks "github.com/absmach/magistrala/consumers/notifiers/mocks"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/supermq/consumers"
smqmocks "github.com/absmach/supermq/consumers/mocks"
@@ -31,8 +31,8 @@ const (
validID = "d4ebb847-5d0e-4e46-bdd9-b6aceaaa3a22"
)
func newService() (notifiers.Service, *authnmocks.Authentication, *mocks.SubscriptionsRepository) {
repo := new(mocks.SubscriptionsRepository)
func newService() (notifiers.Service, *authnmocks.Authentication, *mocks.MockSubscriptionsRepository) {
repo := new(mocks.MockSubscriptionsRepository)
auth := new(authnmocks.Authentication)
notifier := new(smqmocks.Notifier)
idp := uuid.NewMock()
-2
View File
@@ -30,8 +30,6 @@ type PageMetadata struct {
}
// SubscriptionsRepository specifies a Subscription persistence API.
//
//go:generate mockery --name SubscriptionsRepository --output=./mocks --filename repository.go --quiet --note "Copyright (c) Abstract Machines"
type SubscriptionsRepository interface {
// Save persists a subscription. Successful operation is indicated by non-nil
// error response.
+1 -1
View File
@@ -13,4 +13,4 @@ For an in-depth explanation of the usage of `writers`, as well as thorough
understanding of SuperMQ, please check out the [official documentation][doc].
[doc]: https://docs.supermq.abstractmachines.fr
[compose]: ../docker/docker-compose.yml
[compose]: ../docker/docker-compose.yaml
+1 -1
View File
@@ -32,7 +32,7 @@ default values.
## Deployment
The service itself is distributed as Docker container. Check the [`postgres-writer`](https://github.com/absmach/supermq/blob/main/docker/addons/postgres-writer/docker-compose.yml#L34-L59) service section in docker-compose file to see how service is deployed.
The service itself is distributed as Docker container. Check the [`postgres-writer`](https://github.com/absmach/supermq/blob/main/docker/addons/postgres-writer/docker-compose.yaml#L34-L59) service section in docker-compose file to see how service is deployed.
To start the service, execute the following shell script:
+1 -1
View File
@@ -32,7 +32,7 @@ default values.
## Deployment
The service itself is distributed as Docker container. Check the [`timescale-writer`](https://github.com/absmach/supermq/blob/main/docker/addons/timescale-writer/docker-compose.yml#L34-L59) service section in docker-compose file to see how service is deployed.
The service itself is distributed as Docker container. Check the [`timescale-writer`](https://github.com/absmach/supermq/blob/main/docker/addons/timescale-writer/docker-compose.yaml#L34-L59) service section in docker-compose file to see how service is deployed.
To start the service, execute the following shell script:
+3 -3
View File
@@ -13,11 +13,11 @@ Follow the [official documentation](https://docs.docker.com/compose/install/).
Run the following commands from the project root directory.
```bash
docker compose -f docker/docker-compose.yml up
docker compose -f docker/docker-compose.yaml up
```
```bash
docker compose -f docker/addons/<path>/docker-compose.yml up
docker compose -f docker/addons/<path>/docker-compose.yaml up
```
To pull docker images from a specific release you need to change the value of `MG_RELEASE_TAG` in `.env` before running these commands.
@@ -33,7 +33,7 @@ Events store: This is used by Magistrala services to store events for distribute
This is the same as MESSAGE_BROKER. This can either be 'NATS' or 'RabbitMQ' or 'Redis'. If Redis is used as an events store, then RabbitMQ or NATS is used as a message broker.
The current deployment strategy for Magistrala in `docker/docker-compose.yml` is to use VerneMQ as a MQTT_BROKER and NATS as a MESSAGE_BROKER and EVENTS_STORE.
The current deployment strategy for Magistrala in `docker/docker-compose.yaml` is to use VerneMQ as a MQTT_BROKER and NATS as a MESSAGE_BROKER and EVENTS_STORE.
Therefore, the following combinations are possible:
@@ -3,7 +3,7 @@
# This docker-compose file contains optional bootstrap services. Since it's optional, this file is
# dependent of docker-compose file from <project_root>/docker. In order to run this services, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/bootstrap/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/bootstrap/docker-compose.yaml up
# from project root.
networks:
@@ -2,9 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
# This docker-compose file contains optional Postgres-reader service for Magistrala platform.
# Since this service is optional, this file is dependent of docker-compose.yml file
# Since this service is optional, this file is dependent of docker-compose.yaml file
# from <project_root>/docker. In order to run this service, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/postgres-reader/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/postgres-reader/docker-compose.yaml up
# from project root.
networks:
@@ -4,7 +4,7 @@
# This docker-compose file contains optional Postgres and Postgres-writer services
# for Magistrala platform. Since these are optional, this file is dependent of docker-compose file
# from <project_root>/docker. In order to run these services, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/postgres-writer/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/postgres-writer/docker-compose.yaml up
# from project root. PostgreSQL default port (5432) is exposed, so you can use various tools for database
# inspection and data visualization.
@@ -2,9 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
# This docker-compose file contains optional Prometheus and Grafana service for Magistrala platform.
# Since this service is optional, this file is dependent of docker-compose.yml file
# Since this service is optional, this file is dependent of docker-compose.yaml file
# from <project_root>/docker. In order to run this service, execute command:
# docker compose -f docker/addons/prometheus/docker-compose.yml up
# docker compose -f docker/addons/prometheus/docker-compose.yaml up
# from project root.
networks:
@@ -24,8 +24,8 @@ services:
- magistrala-base-net
volumes:
- type: bind
source: ./metrics/prometheus.yml
target: /etc/prometheus/prometheus.yml
source: ./metrics/prometheus.yaml
target: /etc/prometheus/prometheus.yaml
- magistrala-prometheus-volume:/prometheus
grafana:
@@ -43,10 +43,10 @@ services:
- magistrala-base-net
volumes:
- type: bind
source: ./grafana/datasource.yml
target: /etc/grafana/provisioning/datasources/datasource.yml
source: ./grafana/datasource.yaml
target: /etc/grafana/provisioning/datasources/datasource.yaml
- type: bind
source: ./grafana/dashboard.yml
source: ./grafana/dashboard.yaml
target: /etc/grafana/provisioning/dashboards/main.yaml
- type: bind
source: ./grafana/example-dashboard.json
@@ -3,7 +3,7 @@
# This docker-compose file contains optional provision services. Since it's optional, this file is
# dependent of docker-compose file from <project_root>/docker. In order to run this services, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/provision/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/provision/docker-compose.yaml up
# from project root.
networks:
@@ -2,9 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
# This docker-compose file contains optional Timescale-reader service for Magistrala platform.
# Since this service is optional, this file is dependent of docker-compose.yml file
# Since this service is optional, this file is dependent of docker-compose.yaml file
# from <project_root>/docker. In order to run this service, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/timescale-reader/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/timescale-reader/docker-compose.yaml up
# from project root.
networks:
@@ -4,7 +4,7 @@
# This docker-compose file contains optional Timescale and Timescale-writer services
# for Magistrala platform. Since these are optional, this file is dependent of docker-compose file
# from <project_root>/docker. In order to run these services, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/timescale-writer/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/timescale-writer/docker-compose.yaml up
# from project root. PostgreSQL default port (5432) is exposed, so you can use various tools for database
# inspection and data visualization.
@@ -4,7 +4,7 @@
# This docker-compose file contains optional Vault service for Magistrala platform.
# Since this is optional, this file is dependent of docker-compose file
# from <project_root>/docker. In order to run these services, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/vault/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/vault/docker-compose.yaml up
# from project root. Vault default port (8200) is exposed, so you can use Vault CLI tool for
# vault inspection and administration, as well as access the UI.
@@ -5,10 +5,10 @@ name: "magistrala"
include:
- path:
- ./supermq-docker/docker-compose.yml
- ./supermq-docker/addons/journal/docker-compose.yml
- ./supermq-docker/addons/certs/docker-compose.yml
- ./supermq-docker-compose.override.yml
- ./supermq-docker/docker-compose.yaml
- ./supermq-docker/addons/journal/docker-compose.yaml
- ./supermq-docker/addons/certs/docker-compose.yaml
- ./supermq-docker-compose.override.yaml
project_directory: ./supermq-docker
env_file:
- ./supermq-docker/.env
@@ -116,7 +116,7 @@ services:
am-certs:
volumes:
- ./addons/certs/config.yml:/config/config.yml
- ./addons/certs/config.yaml:/config/config.yaml
networks: !override
- magistrala-base-net
+3 -3
View File
@@ -13,11 +13,11 @@ Follow the [official documentation](https://docs.docker.com/compose/install/).
Run the following commands from the project root directory.
```bash
docker compose -f docker/docker-compose.yml up
docker compose -f docker/docker-compose.yaml up
```
```bash
docker compose -f docker/addons/<path>/docker-compose.yml up
docker compose -f docker/addons/<path>/docker-compose.yaml up
```
To pull docker images from a specific release you need to change the value of `SMQ_RELEASE_TAG` in `.env` before running these commands.
@@ -33,7 +33,7 @@ Events store: This is used by SuperMQ services to store events for distributed p
This is the same as MESSAGE_BROKER. This can either be 'NATS' or 'RabbitMQ' or 'Redis'. If Redis is used as an events store, then RabbitMQ or NATS is used as a message broker.
The current deployment strategy for SuperMQ in `docker/docker-compose.yml` is to use RabbitMQ as a MQTT_BROKER and NATS as a MESSAGE_BROKER and EVENTS_STORE.
The current deployment strategy for SuperMQ in `docker/docker-compose.yaml` is to use RabbitMQ as a MQTT_BROKER and NATS as a MESSAGE_BROKER and EVENTS_STORE.
Therefore, the following combinations are possible:
@@ -3,7 +3,7 @@
# This docker-compose file contains optional certs services. Since it's optional, this file is
# dependent of docker-compose file from <project_root>/docker. In order to run this services, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/certs/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/certs/docker-compose.yaml up
# from project root.
networks:
@@ -118,7 +118,7 @@ services:
AM_JAEGER_URL: ${SMQ_JAEGER_URL}
AM_JAEGER_TRACE_RATIO: ${SMQ_JAEGER_TRACE_RATIO}
volumes:
- ./config.yml:/config/config.yml
- ./config.yaml:/config/config.yaml
ports:
- 9010:9010
- 7012:7012
@@ -4,7 +4,7 @@
# This docker-compose file contains optional Postgres and journal services
# for SuperMQ platform. Since these are optional, this file is dependent of docker-compose file
# from <project_root>/docker. In order to run these services, execute command:
# docker-compose -f docker/docker-compose.yml -f docker/addons/journal/docker-compose.yml up
# docker-compose -f docker/docker-compose.yaml -f docker/addons/journal/docker-compose.yaml up
# from project root. PostgreSQL default port (5432) is exposed, so you can use various tools for database
# inspection and data visualization.
@@ -2,9 +2,9 @@
# SPDX-License-Identifier: Apache-2.0
# This docker-compose file contains optional Prometheus and Grafana service for SuperMQ platform.
# Since this service is optional, this file is dependent of docker-compose.yml file
# Since this service is optional, this file is dependent of docker-compose.yaml file
# from <project_root>/docker. In order to run this service, execute command:
# docker compose -f docker/addons/prometheus/docker-compose.yml up
# docker compose -f docker/addons/prometheus/docker-compose.yaml up
# from project root.
networks:
@@ -24,8 +24,8 @@ services:
- supermq-base-net
volumes:
- type: bind
source: ./metrics/prometheus.yml
target: /etc/prometheus/prometheus.yml
source: ./metrics/prometheus.yaml
target: /etc/prometheus/prometheus.yaml
- supermq-prometheus-volume:/prometheus
grafana:
@@ -43,10 +43,10 @@ services:
- supermq-base-net
volumes:
- type: bind
source: ./grafana/datasource.yml
target: /etc/grafana/provisioning/datasources/datasource.yml
source: ./grafana/datasource.yaml
target: /etc/grafana/provisioning/datasources/datasource.yaml
- type: bind
source: ./grafana/dashboard.yml
source: ./grafana/dashboard.yaml
target: /etc/grafana/provisioning/dashboards/main.yaml
- type: bind
source: ./grafana/example-dashboard.json
@@ -4,7 +4,7 @@
# This docker-compose file contains optional Vault service for SuperMQ platform.
# Since this is optional, this file is dependent of docker-compose file
# from <project_root>/docker. In order to run these services, execute command:
# docker compose -f docker/docker-compose.yml -f docker/addons/vault/docker-compose.yml up
# docker compose -f docker/docker-compose.yaml -f docker/addons/vault/docker-compose.yaml up
# from project root. Vault default port (8200) is exposed, so you can use Vault CLI tool for
# vault inspection and administration, as well as access the UI.
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
# These paths are set to its default values as
# a volume in the docker/docker-compose.yml file.
# a volume in the docker/docker-compose.yaml file.
ssl_certificate /etc/ssl/certs/supermq-server.crt;
ssl_certificate_key /etc/ssl/private/supermq-server.key;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
+3 -3
View File
@@ -132,9 +132,9 @@ type readerChannelRes struct {
Metadata interface{} `json:"metadata,omitempty"`
}
func setupBootstrap() (*httptest.Server, *bmocks.Service, *bmocks.ConfigReader, *authnmocks.Authentication) {
bsvc := new(bmocks.Service)
reader := new(bmocks.ConfigReader)
func setupBootstrap() (*httptest.Server, *bmocks.MockService, *bmocks.MockConfigReader, *authnmocks.Authentication) {
bsvc := new(bmocks.MockService)
reader := new(bmocks.MockConfigReader)
logger := smqlog.NewMock()
authn := new(authnmocks.Authentication)
mux := api.MakeHandler(bsvc, authn, reader, logger, "")
+2 -2
View File
@@ -51,8 +51,8 @@ var (
contentType = supermqSDK.CTJSON
)
func setupSubscriptions() (*httptest.Server, *notmocks.Service) {
nsvc := new(notmocks.Service)
func setupSubscriptions() (*httptest.Server, *notmocks.MockService) {
nsvc := new(notmocks.MockService)
logger := smqlog.NewMock()
mux := httpapi.MakeHandler(nsvc, logger, instanceID)
+2213 -2453
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -54,8 +54,6 @@ type MessagePageMetadata struct {
}
// SDK contains Magistrala API.
//
//go:generate mockery --name SDK --output=./mocks --filename sdk.go --quiet --note "Copyright (c) Abstract Machines"
type SDK interface {
smqSDK.SDK
+1 -1
View File
@@ -108,7 +108,7 @@ build/supermq-provision
Docker composition:
```bash
docker compose -f docker/addons/provision/docker-compose.yml up
docker compose -f docker/addons/provision/docker-compose.yaml up
```
For the case that credentials or API token is passed in configuration file or environment variables, call to `/mapping` endpoint doesn't require `Authentication` header:
+3 -3
View File
@@ -14,7 +14,7 @@ import (
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/provision"
"github.com/absmach/magistrala/provision/api"
"github.com/absmach/magistrala/provision/mocks"
mocks "github.com/absmach/magistrala/provision/mocks"
apiutil "github.com/absmach/supermq/api/http/util"
smqlog "github.com/absmach/supermq/logger"
svcerr "github.com/absmach/supermq/pkg/errors/service"
@@ -53,8 +53,8 @@ func (tr testRequest) make() (*http.Response, error) {
return tr.client.Do(req)
}
func newProvisionServer() (*httptest.Server, *mocks.Service) {
svc := new(mocks.Service)
func newProvisionServer() (*httptest.Server, *mocks.MockService) {
svc := new(mocks.MockService)
logger := smqlog.NewMock()
mux := api.MakeHandler(svc, logger, "test")
+147 -55
View File
@@ -1,22 +1,44 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
// Copyright (c) Abstract Machines
package mocks
package provision
import (
provision "github.com/absmach/magistrala/provision"
"github.com/absmach/magistrala/provision"
mock "github.com/stretchr/testify/mock"
)
// Service is an autogenerated mock type for the Service type
type Service struct {
// NewMockService creates a new instance of MockService. 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 NewMockService(t interface {
mock.TestingT
Cleanup(func())
}) *MockService {
mock := &MockService{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockService is an autogenerated mock type for the Service type
type MockService struct {
mock.Mock
}
// Cert provides a mock function with given fields: domainID, token, clientID, duration
func (_m *Service) Cert(domainID string, token string, clientID string, duration string) (string, string, error) {
ret := _m.Called(domainID, token, clientID, duration)
type MockService_Expecter struct {
mock *mock.Mock
}
func (_m *MockService) EXPECT() *MockService_Expecter {
return &MockService_Expecter{mock: &_m.Mock}
}
// Cert provides a mock function for the type MockService
func (_mock *MockService) Cert(domainID string, token string, clientID string, duration string) (string, string, error) {
ret := _mock.Called(domainID, token, clientID, duration)
if len(ret) == 0 {
panic("no return value specified for Cert")
@@ -25,33 +47,61 @@ func (_m *Service) Cert(domainID string, token string, clientID string, duration
var r0 string
var r1 string
var r2 error
if rf, ok := ret.Get(0).(func(string, string, string, string) (string, string, error)); ok {
return rf(domainID, token, clientID, duration)
if returnFunc, ok := ret.Get(0).(func(string, string, string, string) (string, string, error)); ok {
return returnFunc(domainID, token, clientID, duration)
}
if rf, ok := ret.Get(0).(func(string, string, string, string) string); ok {
r0 = rf(domainID, token, clientID, duration)
if returnFunc, ok := ret.Get(0).(func(string, string, string, string) string); ok {
r0 = returnFunc(domainID, token, clientID, duration)
} else {
r0 = ret.Get(0).(string)
}
if rf, ok := ret.Get(1).(func(string, string, string, string) string); ok {
r1 = rf(domainID, token, clientID, duration)
if returnFunc, ok := ret.Get(1).(func(string, string, string, string) string); ok {
r1 = returnFunc(domainID, token, clientID, duration)
} else {
r1 = ret.Get(1).(string)
}
if rf, ok := ret.Get(2).(func(string, string, string, string) error); ok {
r2 = rf(domainID, token, clientID, duration)
if returnFunc, ok := ret.Get(2).(func(string, string, string, string) error); ok {
r2 = returnFunc(domainID, token, clientID, duration)
} else {
r2 = ret.Error(2)
}
return r0, r1, r2
}
// Mapping provides a mock function with given fields: token
func (_m *Service) Mapping(token string) (map[string]interface{}, error) {
ret := _m.Called(token)
// MockService_Cert_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Cert'
type MockService_Cert_Call struct {
*mock.Call
}
// Cert is a helper method to define mock.On call
// - domainID
// - token
// - clientID
// - duration
func (_e *MockService_Expecter) Cert(domainID interface{}, token interface{}, clientID interface{}, duration interface{}) *MockService_Cert_Call {
return &MockService_Cert_Call{Call: _e.mock.On("Cert", domainID, token, clientID, duration)}
}
func (_c *MockService_Cert_Call) Run(run func(domainID string, token string, clientID string, duration string)) *MockService_Cert_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(string), args[1].(string), args[2].(string), args[3].(string))
})
return _c
}
func (_c *MockService_Cert_Call) Return(s string, s1 string, err error) *MockService_Cert_Call {
_c.Call.Return(s, s1, err)
return _c
}
func (_c *MockService_Cert_Call) RunAndReturn(run func(domainID string, token string, clientID string, duration string) (string, string, error)) *MockService_Cert_Call {
_c.Call.Return(run)
return _c
}
// Mapping provides a mock function for the type MockService
func (_mock *MockService) Mapping(token string) (map[string]interface{}, error) {
ret := _mock.Called(token)
if len(ret) == 0 {
panic("no return value specified for Mapping")
@@ -59,29 +109,55 @@ func (_m *Service) Mapping(token string) (map[string]interface{}, error) {
var r0 map[string]interface{}
var r1 error
if rf, ok := ret.Get(0).(func(string) (map[string]interface{}, error)); ok {
return rf(token)
if returnFunc, ok := ret.Get(0).(func(string) (map[string]interface{}, error)); ok {
return returnFunc(token)
}
if rf, ok := ret.Get(0).(func(string) map[string]interface{}); ok {
r0 = rf(token)
if returnFunc, ok := ret.Get(0).(func(string) map[string]interface{}); ok {
r0 = returnFunc(token)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(map[string]interface{})
}
}
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(token)
if returnFunc, ok := ret.Get(1).(func(string) error); ok {
r1 = returnFunc(token)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Provision provides a mock function with given fields: domainID, token, name, externalID, externalKey
func (_m *Service) Provision(domainID string, token string, name string, externalID string, externalKey string) (provision.Result, error) {
ret := _m.Called(domainID, token, name, externalID, externalKey)
// MockService_Mapping_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Mapping'
type MockService_Mapping_Call struct {
*mock.Call
}
// Mapping is a helper method to define mock.On call
// - token
func (_e *MockService_Expecter) Mapping(token interface{}) *MockService_Mapping_Call {
return &MockService_Mapping_Call{Call: _e.mock.On("Mapping", token)}
}
func (_c *MockService_Mapping_Call) Run(run func(token string)) *MockService_Mapping_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(string))
})
return _c
}
func (_c *MockService_Mapping_Call) Return(stringToIfaceVal map[string]interface{}, err error) *MockService_Mapping_Call {
_c.Call.Return(stringToIfaceVal, err)
return _c
}
func (_c *MockService_Mapping_Call) RunAndReturn(run func(token string) (map[string]interface{}, error)) *MockService_Mapping_Call {
_c.Call.Return(run)
return _c
}
// Provision provides a mock function for the type MockService
func (_mock *MockService) Provision(domainID string, token string, name string, externalID string, externalKey string) (provision.Result, error) {
ret := _mock.Called(domainID, token, name, externalID, externalKey)
if len(ret) == 0 {
panic("no return value specified for Provision")
@@ -89,34 +165,50 @@ func (_m *Service) Provision(domainID string, token string, name string, externa
var r0 provision.Result
var r1 error
if rf, ok := ret.Get(0).(func(string, string, string, string, string) (provision.Result, error)); ok {
return rf(domainID, token, name, externalID, externalKey)
if returnFunc, ok := ret.Get(0).(func(string, string, string, string, string) (provision.Result, error)); ok {
return returnFunc(domainID, token, name, externalID, externalKey)
}
if rf, ok := ret.Get(0).(func(string, string, string, string, string) provision.Result); ok {
r0 = rf(domainID, token, name, externalID, externalKey)
if returnFunc, ok := ret.Get(0).(func(string, string, string, string, string) provision.Result); ok {
r0 = returnFunc(domainID, token, name, externalID, externalKey)
} else {
r0 = ret.Get(0).(provision.Result)
}
if rf, ok := ret.Get(1).(func(string, string, string, string, string) error); ok {
r1 = rf(domainID, token, name, externalID, externalKey)
if returnFunc, ok := ret.Get(1).(func(string, string, string, string, string) error); ok {
r1 = returnFunc(domainID, token, name, externalID, externalKey)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// 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
// MockService_Provision_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Provision'
type MockService_Provision_Call struct {
*mock.Call
}
// Provision is a helper method to define mock.On call
// - domainID
// - token
// - name
// - externalID
// - externalKey
func (_e *MockService_Expecter) Provision(domainID interface{}, token interface{}, name interface{}, externalID interface{}, externalKey interface{}) *MockService_Provision_Call {
return &MockService_Provision_Call{Call: _e.mock.On("Provision", domainID, token, name, externalID, externalKey)}
}
func (_c *MockService_Provision_Call) Run(run func(domainID string, token string, name string, externalID string, externalKey string)) *MockService_Provision_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(string), args[1].(string), args[2].(string), args[3].(string), args[4].(string))
})
return _c
}
func (_c *MockService_Provision_Call) Return(result provision.Result, err error) *MockService_Provision_Call {
_c.Call.Return(result, err)
return _c
}
func (_c *MockService_Provision_Call) RunAndReturn(run func(domainID string, token string, name string, externalID string, externalKey string) (provision.Result, error)) *MockService_Provision_Call {
_c.Call.Return(run)
return _c
}
-2
View File
@@ -48,8 +48,6 @@ var (
var _ Service = (*provisionService)(nil)
// Service specifies Provision service API.
//
//go:generate mockery --name Service --output=./mocks --filename service.go --quiet --note "Copyright (c) Abstract Machines"
type Service interface {
// Provision is the only method this API specifies. Depending on the configuration,
// the following actions will can be executed:
+2 -2
View File
@@ -190,7 +190,7 @@ To start the Rules Engine service, run:
make run_addons re
```
This command starts the Rules Engine service using Docker Compose with the configuration defined in [docker-compose.yml][compose].
This command starts the Rules Engine service using Docker Compose with the configuration defined in [docker-compose.yaml][compose].
## For More Information
@@ -198,4 +198,4 @@ This command starts the Rules Engine service using Docker Compose with the confi
- [Docker Compose][compose]
[doc]: https://docs.magistrala.abstractmachines.fr
[compose]: ../docker/docker-compose.yml
[compose]: ../docker/docker-compose.yaml
+3 -3
View File
@@ -18,7 +18,7 @@ import (
"github.com/absmach/magistrala/pkg/errors"
"github.com/absmach/magistrala/re"
"github.com/absmach/magistrala/re/api"
"github.com/absmach/magistrala/re/mocks"
mocks "github.com/absmach/magistrala/re/mocks"
apiutil "github.com/absmach/supermq/api/http/util"
"github.com/absmach/supermq/auth"
smqlog "github.com/absmach/supermq/logger"
@@ -85,8 +85,8 @@ func (tr testRequest) make() (*http.Response, error) {
return tr.client.Do(req)
}
func newRuleEngineServer() (*httptest.Server, *mocks.Service, *authnmocks.Authentication) {
svc := new(mocks.Service)
func newRuleEngineServer() (*httptest.Server, *mocks.MockService, *authnmocks.Authentication) {
svc := new(mocks.MockService)
authn := new(authnmocks.Authentication)
logger := smqlog.NewMock()
-189
View File
@@ -1,189 +0,0 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Copyright (c) Abstract Machines
package mocks
import (
context "context"
re "github.com/absmach/magistrala/re"
mock "github.com/stretchr/testify/mock"
)
// Repository is an autogenerated mock type for the Repository type
type Repository struct {
mock.Mock
}
// AddRule provides a mock function with given fields: ctx, r
func (_m *Repository) AddRule(ctx context.Context, r re.Rule) (re.Rule, error) {
ret := _m.Called(ctx, r)
if len(ret) == 0 {
panic("no return value specified for AddRule")
}
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, re.Rule) (re.Rule, error)); ok {
return rf(ctx, r)
}
if rf, ok := ret.Get(0).(func(context.Context, re.Rule) re.Rule); ok {
r0 = rf(ctx, r)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, re.Rule) error); ok {
r1 = rf(ctx, r)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ListRules provides a mock function with given fields: ctx, pm
func (_m *Repository) ListRules(ctx context.Context, pm re.PageMeta) (re.Page, error) {
ret := _m.Called(ctx, pm)
if len(ret) == 0 {
panic("no return value specified for ListRules")
}
var r0 re.Page
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, re.PageMeta) (re.Page, error)); ok {
return rf(ctx, pm)
}
if rf, ok := ret.Get(0).(func(context.Context, re.PageMeta) re.Page); ok {
r0 = rf(ctx, pm)
} else {
r0 = ret.Get(0).(re.Page)
}
if rf, ok := ret.Get(1).(func(context.Context, re.PageMeta) error); ok {
r1 = rf(ctx, pm)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// RemoveRule provides a mock function with given fields: ctx, id
func (_m *Repository) RemoveRule(ctx context.Context, id string) error {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for RemoveRule")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateRule provides a mock function with given fields: ctx, r
func (_m *Repository) UpdateRule(ctx context.Context, r re.Rule) (re.Rule, error) {
ret := _m.Called(ctx, r)
if len(ret) == 0 {
panic("no return value specified for UpdateRule")
}
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, re.Rule) (re.Rule, error)); ok {
return rf(ctx, r)
}
if rf, ok := ret.Get(0).(func(context.Context, re.Rule) re.Rule); ok {
r0 = rf(ctx, r)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, re.Rule) error); ok {
r1 = rf(ctx, r)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// UpdateRuleStatus provides a mock function with given fields: ctx, id, status
func (_m *Repository) UpdateRuleStatus(ctx context.Context, id string, status re.Status) (re.Rule, error) {
ret := _m.Called(ctx, id, status)
if len(ret) == 0 {
panic("no return value specified for UpdateRuleStatus")
}
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string, re.Status) (re.Rule, error)); ok {
return rf(ctx, id, status)
}
if rf, ok := ret.Get(0).(func(context.Context, string, re.Status) re.Rule); ok {
r0 = rf(ctx, id, status)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, string, re.Status) error); ok {
r1 = rf(ctx, id, status)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ViewRule provides a mock function with given fields: ctx, id
func (_m *Repository) ViewRule(ctx context.Context, id string) (re.Rule, error) {
ret := _m.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for ViewRule")
}
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, string) (re.Rule, error)); ok {
return rf(ctx, id)
}
if rf, ok := ret.Get(0).(func(context.Context, string) re.Rule); ok {
r0 = rf(ctx, id)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, string) error); ok {
r1 = rf(ctx, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// NewRepository creates a new instance of Repository. 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 NewRepository(t interface {
mock.TestingT
Cleanup(func())
}) *Repository {
mock := &Repository{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
+361
View File
@@ -0,0 +1,361 @@
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
package re
import (
"context"
"github.com/absmach/magistrala/re"
mock "github.com/stretchr/testify/mock"
)
// NewMockRepository creates a new instance of MockRepository. 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 NewMockRepository(t interface {
mock.TestingT
Cleanup(func())
}) *MockRepository {
mock := &MockRepository{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockRepository is an autogenerated mock type for the Repository type
type MockRepository struct {
mock.Mock
}
type MockRepository_Expecter struct {
mock *mock.Mock
}
func (_m *MockRepository) EXPECT() *MockRepository_Expecter {
return &MockRepository_Expecter{mock: &_m.Mock}
}
// AddRule provides a mock function for the type MockRepository
func (_mock *MockRepository) AddRule(ctx context.Context, r re.Rule) (re.Rule, error) {
ret := _mock.Called(ctx, r)
if len(ret) == 0 {
panic("no return value specified for AddRule")
}
var r0 re.Rule
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, re.Rule) (re.Rule, error)); ok {
return returnFunc(ctx, r)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, re.Rule) re.Rule); ok {
r0 = returnFunc(ctx, r)
} else {
r0 = ret.Get(0).(re.Rule)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, re.Rule) error); ok {
r1 = returnFunc(ctx, r)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockRepository_AddRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddRule'
type MockRepository_AddRule_Call struct {
*mock.Call
}
// AddRule is a helper method to define mock.On call
// - ctx
// - r
func (_e *MockRepository_Expecter) AddRule(ctx interface{}, r interface{}) *MockRepository_AddRule_Call {
return &MockRepository_AddRule_Call{Call: _e.mock.On("AddRule", ctx, r)}
}
func (_c *MockRepository_AddRule_Call) Run(run func(ctx context.Context, r re.Rule)) *MockRepository_AddRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(re.Rule))
})
return _c
}
func (_c *MockRepository_AddRule_Call) Return(rule re.Rule, err error) *MockRepository_AddRule_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockRepository_AddRule_Call) RunAndReturn(run func(ctx context.Context, r re.Rule) (re.Rule, error)) *MockRepository_AddRule_Call {
_c.Call.Return(run)
return _c
}
// ListRules provides a mock function for the type MockRepository
func (_mock *MockRepository) ListRules(ctx context.Context, pm re.PageMeta) (re.Page, error) {
ret := _mock.Called(ctx, pm)
if len(ret) == 0 {
panic("no return value specified for ListRules")
}
var r0 re.Page
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, re.PageMeta) (re.Page, error)); ok {
return returnFunc(ctx, pm)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, re.PageMeta) re.Page); ok {
r0 = returnFunc(ctx, pm)
} else {
r0 = ret.Get(0).(re.Page)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, re.PageMeta) error); ok {
r1 = returnFunc(ctx, pm)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockRepository_ListRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRules'
type MockRepository_ListRules_Call struct {
*mock.Call
}
// ListRules is a helper method to define mock.On call
// - ctx
// - pm
func (_e *MockRepository_Expecter) ListRules(ctx interface{}, pm interface{}) *MockRepository_ListRules_Call {
return &MockRepository_ListRules_Call{Call: _e.mock.On("ListRules", ctx, pm)}
}
func (_c *MockRepository_ListRules_Call) Run(run func(ctx context.Context, pm re.PageMeta)) *MockRepository_ListRules_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(re.PageMeta))
})
return _c
}
func (_c *MockRepository_ListRules_Call) Return(page re.Page, err error) *MockRepository_ListRules_Call {
_c.Call.Return(page, err)
return _c
}
func (_c *MockRepository_ListRules_Call) RunAndReturn(run func(ctx context.Context, pm re.PageMeta) (re.Page, error)) *MockRepository_ListRules_Call {
_c.Call.Return(run)
return _c
}
// RemoveRule provides a mock function for the type MockRepository
func (_mock *MockRepository) RemoveRule(ctx context.Context, id string) error {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for RemoveRule")
}
var r0 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockRepository_RemoveRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRule'
type MockRepository_RemoveRule_Call struct {
*mock.Call
}
// RemoveRule is a helper method to define mock.On call
// - ctx
// - id
func (_e *MockRepository_Expecter) RemoveRule(ctx interface{}, id interface{}) *MockRepository_RemoveRule_Call {
return &MockRepository_RemoveRule_Call{Call: _e.mock.On("RemoveRule", ctx, id)}
}
func (_c *MockRepository_RemoveRule_Call) Run(run func(ctx context.Context, id string)) *MockRepository_RemoveRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockRepository_RemoveRule_Call) Return(err error) *MockRepository_RemoveRule_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockRepository_RemoveRule_Call) RunAndReturn(run func(ctx context.Context, id string) error) *MockRepository_RemoveRule_Call {
_c.Call.Return(run)
return _c
}
// UpdateRule provides a mock function for the type MockRepository
func (_mock *MockRepository) UpdateRule(ctx context.Context, r re.Rule) (re.Rule, error) {
ret := _mock.Called(ctx, r)
if len(ret) == 0 {
panic("no return value specified for UpdateRule")
}
var r0 re.Rule
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, re.Rule) (re.Rule, error)); ok {
return returnFunc(ctx, r)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, re.Rule) re.Rule); ok {
r0 = returnFunc(ctx, r)
} else {
r0 = ret.Get(0).(re.Rule)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, re.Rule) error); ok {
r1 = returnFunc(ctx, r)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockRepository_UpdateRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRule'
type MockRepository_UpdateRule_Call struct {
*mock.Call
}
// UpdateRule is a helper method to define mock.On call
// - ctx
// - r
func (_e *MockRepository_Expecter) UpdateRule(ctx interface{}, r interface{}) *MockRepository_UpdateRule_Call {
return &MockRepository_UpdateRule_Call{Call: _e.mock.On("UpdateRule", ctx, r)}
}
func (_c *MockRepository_UpdateRule_Call) Run(run func(ctx context.Context, r re.Rule)) *MockRepository_UpdateRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(re.Rule))
})
return _c
}
func (_c *MockRepository_UpdateRule_Call) Return(rule re.Rule, err error) *MockRepository_UpdateRule_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockRepository_UpdateRule_Call) RunAndReturn(run func(ctx context.Context, r re.Rule) (re.Rule, error)) *MockRepository_UpdateRule_Call {
_c.Call.Return(run)
return _c
}
// UpdateRuleStatus provides a mock function for the type MockRepository
func (_mock *MockRepository) UpdateRuleStatus(ctx context.Context, id string, status re.Status) (re.Rule, error) {
ret := _mock.Called(ctx, id, status)
if len(ret) == 0 {
panic("no return value specified for UpdateRuleStatus")
}
var r0 re.Rule
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string, re.Status) (re.Rule, error)); ok {
return returnFunc(ctx, id, status)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, string, re.Status) re.Rule); ok {
r0 = returnFunc(ctx, id, status)
} else {
r0 = ret.Get(0).(re.Rule)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, string, re.Status) error); ok {
r1 = returnFunc(ctx, id, status)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockRepository_UpdateRuleStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRuleStatus'
type MockRepository_UpdateRuleStatus_Call struct {
*mock.Call
}
// UpdateRuleStatus is a helper method to define mock.On call
// - ctx
// - id
// - status
func (_e *MockRepository_Expecter) UpdateRuleStatus(ctx interface{}, id interface{}, status interface{}) *MockRepository_UpdateRuleStatus_Call {
return &MockRepository_UpdateRuleStatus_Call{Call: _e.mock.On("UpdateRuleStatus", ctx, id, status)}
}
func (_c *MockRepository_UpdateRuleStatus_Call) Run(run func(ctx context.Context, id string, status re.Status)) *MockRepository_UpdateRuleStatus_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string), args[2].(re.Status))
})
return _c
}
func (_c *MockRepository_UpdateRuleStatus_Call) Return(rule re.Rule, err error) *MockRepository_UpdateRuleStatus_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockRepository_UpdateRuleStatus_Call) RunAndReturn(run func(ctx context.Context, id string, status re.Status) (re.Rule, error)) *MockRepository_UpdateRuleStatus_Call {
_c.Call.Return(run)
return _c
}
// ViewRule provides a mock function for the type MockRepository
func (_mock *MockRepository) ViewRule(ctx context.Context, id string) (re.Rule, error) {
ret := _mock.Called(ctx, id)
if len(ret) == 0 {
panic("no return value specified for ViewRule")
}
var r0 re.Rule
var r1 error
if returnFunc, ok := ret.Get(0).(func(context.Context, string) (re.Rule, error)); ok {
return returnFunc(ctx, id)
}
if returnFunc, ok := ret.Get(0).(func(context.Context, string) re.Rule); ok {
r0 = returnFunc(ctx, id)
} else {
r0 = ret.Get(0).(re.Rule)
}
if returnFunc, ok := ret.Get(1).(func(context.Context, string) error); ok {
r1 = returnFunc(ctx, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockRepository_ViewRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ViewRule'
type MockRepository_ViewRule_Call struct {
*mock.Call
}
// ViewRule is a helper method to define mock.On call
// - ctx
// - id
func (_e *MockRepository_Expecter) ViewRule(ctx interface{}, id interface{}) *MockRepository_ViewRule_Call {
return &MockRepository_ViewRule_Call{Call: _e.mock.On("ViewRule", ctx, id)}
}
func (_c *MockRepository_ViewRule_Call) Run(run func(ctx context.Context, id string)) *MockRepository_ViewRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(string))
})
return _c
}
func (_c *MockRepository_ViewRule_Call) Return(rule re.Rule, err error) *MockRepository_ViewRule_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockRepository_ViewRule_Call) RunAndReturn(run func(ctx context.Context, id string) (re.Rule, error)) *MockRepository_ViewRule_Call {
_c.Call.Return(run)
return _c
}
+396 -110
View File
@@ -1,27 +1,47 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
// Copyright (c) Abstract Machines
package mocks
package re
import (
context "context"
authn "github.com/absmach/supermq/pkg/authn"
"context"
"github.com/absmach/magistrala/re"
"github.com/absmach/supermq/pkg/authn"
mock "github.com/stretchr/testify/mock"
re "github.com/absmach/magistrala/re"
)
// Service is an autogenerated mock type for the Service type
type Service struct {
// NewMockService creates a new instance of MockService. 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 NewMockService(t interface {
mock.TestingT
Cleanup(func())
}) *MockService {
mock := &MockService{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockService is an autogenerated mock type for the Service type
type MockService struct {
mock.Mock
}
// AddRule provides a mock function with given fields: ctx, session, r
func (_m *Service) AddRule(ctx context.Context, session authn.Session, r re.Rule) (re.Rule, error) {
ret := _m.Called(ctx, session, r)
type MockService_Expecter struct {
mock *mock.Mock
}
func (_m *MockService) EXPECT() *MockService_Expecter {
return &MockService_Expecter{mock: &_m.Mock}
}
// AddRule provides a mock function for the type MockService
func (_mock *MockService) AddRule(ctx context.Context, session authn.Session, r re.Rule) (re.Rule, error) {
ret := _mock.Called(ctx, session, r)
if len(ret) == 0 {
panic("no return value specified for AddRule")
@@ -29,32 +49,90 @@ func (_m *Service) AddRule(ctx context.Context, session authn.Session, r re.Rule
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, re.Rule) (re.Rule, error)); ok {
return rf(ctx, session, r)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, re.Rule) (re.Rule, error)); ok {
return returnFunc(ctx, session, r)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, re.Rule) re.Rule); ok {
r0 = rf(ctx, session, r)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, re.Rule) re.Rule); ok {
r0 = returnFunc(ctx, session, r)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, re.Rule) error); ok {
r1 = rf(ctx, session, r)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, re.Rule) error); ok {
r1 = returnFunc(ctx, session, r)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ConsumeAsync provides a mock function with given fields: ctx, messages
func (_m *Service) ConsumeAsync(ctx context.Context, messages interface{}) {
_m.Called(ctx, messages)
// MockService_AddRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddRule'
type MockService_AddRule_Call struct {
*mock.Call
}
// DisableRule provides a mock function with given fields: ctx, session, id
func (_m *Service) DisableRule(ctx context.Context, session authn.Session, id string) (re.Rule, error) {
ret := _m.Called(ctx, session, id)
// AddRule is a helper method to define mock.On call
// - ctx
// - session
// - r
func (_e *MockService_Expecter) AddRule(ctx interface{}, session interface{}, r interface{}) *MockService_AddRule_Call {
return &MockService_AddRule_Call{Call: _e.mock.On("AddRule", ctx, session, r)}
}
func (_c *MockService_AddRule_Call) Run(run func(ctx context.Context, session authn.Session, r re.Rule)) *MockService_AddRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(re.Rule))
})
return _c
}
func (_c *MockService_AddRule_Call) Return(rule re.Rule, err error) *MockService_AddRule_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockService_AddRule_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, r re.Rule) (re.Rule, error)) *MockService_AddRule_Call {
_c.Call.Return(run)
return _c
}
// ConsumeAsync provides a mock function for the type MockService
func (_mock *MockService) ConsumeAsync(ctx context.Context, messages interface{}) {
_mock.Called(ctx, messages)
return
}
// MockService_ConsumeAsync_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ConsumeAsync'
type MockService_ConsumeAsync_Call struct {
*mock.Call
}
// ConsumeAsync is a helper method to define mock.On call
// - ctx
// - messages
func (_e *MockService_Expecter) ConsumeAsync(ctx interface{}, messages interface{}) *MockService_ConsumeAsync_Call {
return &MockService_ConsumeAsync_Call{Call: _e.mock.On("ConsumeAsync", ctx, messages)}
}
func (_c *MockService_ConsumeAsync_Call) Run(run func(ctx context.Context, messages interface{})) *MockService_ConsumeAsync_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(interface{}))
})
return _c
}
func (_c *MockService_ConsumeAsync_Call) Return() *MockService_ConsumeAsync_Call {
_c.Call.Return()
return _c
}
func (_c *MockService_ConsumeAsync_Call) RunAndReturn(run func(ctx context.Context, messages interface{})) *MockService_ConsumeAsync_Call {
_c.Run(run)
return _c
}
// DisableRule provides a mock function for the type MockService
func (_mock *MockService) DisableRule(ctx context.Context, session authn.Session, id string) (re.Rule, error) {
ret := _mock.Called(ctx, session, id)
if len(ret) == 0 {
panic("no return value specified for DisableRule")
@@ -62,27 +140,55 @@ func (_m *Service) DisableRule(ctx context.Context, session authn.Session, id st
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) (re.Rule, error)); ok {
return rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) (re.Rule, error)); ok {
return returnFunc(ctx, session, id)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) re.Rule); ok {
r0 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) re.Rule); ok {
r0 = returnFunc(ctx, session, id)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string) error); ok {
r1 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, string) error); ok {
r1 = returnFunc(ctx, session, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// EnableRule provides a mock function with given fields: ctx, session, id
func (_m *Service) EnableRule(ctx context.Context, session authn.Session, id string) (re.Rule, error) {
ret := _m.Called(ctx, session, id)
// MockService_DisableRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DisableRule'
type MockService_DisableRule_Call struct {
*mock.Call
}
// DisableRule is a helper method to define mock.On call
// - ctx
// - session
// - id
func (_e *MockService_Expecter) DisableRule(ctx interface{}, session interface{}, id interface{}) *MockService_DisableRule_Call {
return &MockService_DisableRule_Call{Call: _e.mock.On("DisableRule", ctx, session, id)}
}
func (_c *MockService_DisableRule_Call) Run(run func(ctx context.Context, session authn.Session, id string)) *MockService_DisableRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string))
})
return _c
}
func (_c *MockService_DisableRule_Call) Return(rule re.Rule, err error) *MockService_DisableRule_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockService_DisableRule_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, id string) (re.Rule, error)) *MockService_DisableRule_Call {
_c.Call.Return(run)
return _c
}
// EnableRule provides a mock function for the type MockService
func (_mock *MockService) EnableRule(ctx context.Context, session authn.Session, id string) (re.Rule, error) {
ret := _mock.Called(ctx, session, id)
if len(ret) == 0 {
panic("no return value specified for EnableRule")
@@ -90,47 +196,101 @@ func (_m *Service) EnableRule(ctx context.Context, session authn.Session, id str
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) (re.Rule, error)); ok {
return rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) (re.Rule, error)); ok {
return returnFunc(ctx, session, id)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) re.Rule); ok {
r0 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) re.Rule); ok {
r0 = returnFunc(ctx, session, id)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string) error); ok {
r1 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, string) error); ok {
r1 = returnFunc(ctx, session, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// Errors provides a mock function with no fields
func (_m *Service) Errors() <-chan error {
ret := _m.Called()
// MockService_EnableRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnableRule'
type MockService_EnableRule_Call struct {
*mock.Call
}
// EnableRule is a helper method to define mock.On call
// - ctx
// - session
// - id
func (_e *MockService_Expecter) EnableRule(ctx interface{}, session interface{}, id interface{}) *MockService_EnableRule_Call {
return &MockService_EnableRule_Call{Call: _e.mock.On("EnableRule", ctx, session, id)}
}
func (_c *MockService_EnableRule_Call) Run(run func(ctx context.Context, session authn.Session, id string)) *MockService_EnableRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string))
})
return _c
}
func (_c *MockService_EnableRule_Call) Return(rule re.Rule, err error) *MockService_EnableRule_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockService_EnableRule_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, id string) (re.Rule, error)) *MockService_EnableRule_Call {
_c.Call.Return(run)
return _c
}
// Errors provides a mock function for the type MockService
func (_mock *MockService) Errors() <-chan error {
ret := _mock.Called()
if len(ret) == 0 {
panic("no return value specified for Errors")
}
var r0 <-chan error
if rf, ok := ret.Get(0).(func() <-chan error); ok {
r0 = rf()
if returnFunc, ok := ret.Get(0).(func() <-chan error); ok {
r0 = returnFunc()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(<-chan error)
}
}
return r0
}
// ListRules provides a mock function with given fields: ctx, session, pm
func (_m *Service) ListRules(ctx context.Context, session authn.Session, pm re.PageMeta) (re.Page, error) {
ret := _m.Called(ctx, session, pm)
// MockService_Errors_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Errors'
type MockService_Errors_Call struct {
*mock.Call
}
// Errors is a helper method to define mock.On call
func (_e *MockService_Expecter) Errors() *MockService_Errors_Call {
return &MockService_Errors_Call{Call: _e.mock.On("Errors")}
}
func (_c *MockService_Errors_Call) Run(run func()) *MockService_Errors_Call {
_c.Call.Run(func(args mock.Arguments) {
run()
})
return _c
}
func (_c *MockService_Errors_Call) Return(errCh <-chan error) *MockService_Errors_Call {
_c.Call.Return(errCh)
return _c
}
func (_c *MockService_Errors_Call) RunAndReturn(run func() <-chan error) *MockService_Errors_Call {
_c.Call.Return(run)
return _c
}
// ListRules provides a mock function for the type MockService
func (_mock *MockService) ListRules(ctx context.Context, session authn.Session, pm re.PageMeta) (re.Page, error) {
ret := _mock.Called(ctx, session, pm)
if len(ret) == 0 {
panic("no return value specified for ListRules")
@@ -138,63 +298,147 @@ func (_m *Service) ListRules(ctx context.Context, session authn.Session, pm re.P
var r0 re.Page
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, re.PageMeta) (re.Page, error)); ok {
return rf(ctx, session, pm)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, re.PageMeta) (re.Page, error)); ok {
return returnFunc(ctx, session, pm)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, re.PageMeta) re.Page); ok {
r0 = rf(ctx, session, pm)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, re.PageMeta) re.Page); ok {
r0 = returnFunc(ctx, session, pm)
} else {
r0 = ret.Get(0).(re.Page)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, re.PageMeta) error); ok {
r1 = rf(ctx, session, pm)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, re.PageMeta) error); ok {
r1 = returnFunc(ctx, session, pm)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// RemoveRule provides a mock function with given fields: ctx, session, id
func (_m *Service) RemoveRule(ctx context.Context, session authn.Session, id string) error {
ret := _m.Called(ctx, session, id)
// MockService_ListRules_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListRules'
type MockService_ListRules_Call struct {
*mock.Call
}
// ListRules is a helper method to define mock.On call
// - ctx
// - session
// - pm
func (_e *MockService_Expecter) ListRules(ctx interface{}, session interface{}, pm interface{}) *MockService_ListRules_Call {
return &MockService_ListRules_Call{Call: _e.mock.On("ListRules", ctx, session, pm)}
}
func (_c *MockService_ListRules_Call) Run(run func(ctx context.Context, session authn.Session, pm re.PageMeta)) *MockService_ListRules_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(re.PageMeta))
})
return _c
}
func (_c *MockService_ListRules_Call) Return(page re.Page, err error) *MockService_ListRules_Call {
_c.Call.Return(page, err)
return _c
}
func (_c *MockService_ListRules_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, pm re.PageMeta) (re.Page, error)) *MockService_ListRules_Call {
_c.Call.Return(run)
return _c
}
// RemoveRule provides a mock function for the type MockService
func (_mock *MockService) RemoveRule(ctx context.Context, session authn.Session, id string) error {
ret := _mock.Called(ctx, session, id)
if len(ret) == 0 {
panic("no return value specified for RemoveRule")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) error); ok {
r0 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) error); ok {
r0 = returnFunc(ctx, session, id)
} else {
r0 = ret.Error(0)
}
return r0
}
// StartScheduler provides a mock function with given fields: ctx
func (_m *Service) StartScheduler(ctx context.Context) error {
ret := _m.Called(ctx)
// MockService_RemoveRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveRule'
type MockService_RemoveRule_Call struct {
*mock.Call
}
// RemoveRule is a helper method to define mock.On call
// - ctx
// - session
// - id
func (_e *MockService_Expecter) RemoveRule(ctx interface{}, session interface{}, id interface{}) *MockService_RemoveRule_Call {
return &MockService_RemoveRule_Call{Call: _e.mock.On("RemoveRule", ctx, session, id)}
}
func (_c *MockService_RemoveRule_Call) Run(run func(ctx context.Context, session authn.Session, id string)) *MockService_RemoveRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string))
})
return _c
}
func (_c *MockService_RemoveRule_Call) Return(err error) *MockService_RemoveRule_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_RemoveRule_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, id string) error) *MockService_RemoveRule_Call {
_c.Call.Return(run)
return _c
}
// StartScheduler provides a mock function for the type MockService
func (_mock *MockService) StartScheduler(ctx context.Context) error {
ret := _mock.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for StartScheduler")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
if returnFunc, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = returnFunc(ctx)
} else {
r0 = ret.Error(0)
}
return r0
}
// UpdateRule provides a mock function with given fields: ctx, session, r
func (_m *Service) UpdateRule(ctx context.Context, session authn.Session, r re.Rule) (re.Rule, error) {
ret := _m.Called(ctx, session, r)
// MockService_StartScheduler_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartScheduler'
type MockService_StartScheduler_Call struct {
*mock.Call
}
// StartScheduler is a helper method to define mock.On call
// - ctx
func (_e *MockService_Expecter) StartScheduler(ctx interface{}) *MockService_StartScheduler_Call {
return &MockService_StartScheduler_Call{Call: _e.mock.On("StartScheduler", ctx)}
}
func (_c *MockService_StartScheduler_Call) Run(run func(ctx context.Context)) *MockService_StartScheduler_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context))
})
return _c
}
func (_c *MockService_StartScheduler_Call) Return(err error) *MockService_StartScheduler_Call {
_c.Call.Return(err)
return _c
}
func (_c *MockService_StartScheduler_Call) RunAndReturn(run func(ctx context.Context) error) *MockService_StartScheduler_Call {
_c.Call.Return(run)
return _c
}
// UpdateRule provides a mock function for the type MockService
func (_mock *MockService) UpdateRule(ctx context.Context, session authn.Session, r re.Rule) (re.Rule, error) {
ret := _mock.Called(ctx, session, r)
if len(ret) == 0 {
panic("no return value specified for UpdateRule")
@@ -202,27 +446,55 @@ func (_m *Service) UpdateRule(ctx context.Context, session authn.Session, r re.R
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, re.Rule) (re.Rule, error)); ok {
return rf(ctx, session, r)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, re.Rule) (re.Rule, error)); ok {
return returnFunc(ctx, session, r)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, re.Rule) re.Rule); ok {
r0 = rf(ctx, session, r)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, re.Rule) re.Rule); ok {
r0 = returnFunc(ctx, session, r)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, re.Rule) error); ok {
r1 = rf(ctx, session, r)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, re.Rule) error); ok {
r1 = returnFunc(ctx, session, r)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ViewRule provides a mock function with given fields: ctx, session, id
func (_m *Service) ViewRule(ctx context.Context, session authn.Session, id string) (re.Rule, error) {
ret := _m.Called(ctx, session, id)
// MockService_UpdateRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateRule'
type MockService_UpdateRule_Call struct {
*mock.Call
}
// UpdateRule is a helper method to define mock.On call
// - ctx
// - session
// - r
func (_e *MockService_Expecter) UpdateRule(ctx interface{}, session interface{}, r interface{}) *MockService_UpdateRule_Call {
return &MockService_UpdateRule_Call{Call: _e.mock.On("UpdateRule", ctx, session, r)}
}
func (_c *MockService_UpdateRule_Call) Run(run func(ctx context.Context, session authn.Session, r re.Rule)) *MockService_UpdateRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(re.Rule))
})
return _c
}
func (_c *MockService_UpdateRule_Call) Return(rule re.Rule, err error) *MockService_UpdateRule_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockService_UpdateRule_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, r re.Rule) (re.Rule, error)) *MockService_UpdateRule_Call {
_c.Call.Return(run)
return _c
}
// ViewRule provides a mock function for the type MockService
func (_mock *MockService) ViewRule(ctx context.Context, session authn.Session, id string) (re.Rule, error) {
ret := _mock.Called(ctx, session, id)
if len(ret) == 0 {
panic("no return value specified for ViewRule")
@@ -230,34 +502,48 @@ func (_m *Service) ViewRule(ctx context.Context, session authn.Session, id strin
var r0 re.Rule
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) (re.Rule, error)); ok {
return rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) (re.Rule, error)); ok {
return returnFunc(ctx, session, id)
}
if rf, ok := ret.Get(0).(func(context.Context, authn.Session, string) re.Rule); ok {
r0 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(0).(func(context.Context, authn.Session, string) re.Rule); ok {
r0 = returnFunc(ctx, session, id)
} else {
r0 = ret.Get(0).(re.Rule)
}
if rf, ok := ret.Get(1).(func(context.Context, authn.Session, string) error); ok {
r1 = rf(ctx, session, id)
if returnFunc, ok := ret.Get(1).(func(context.Context, authn.Session, string) error); ok {
r1 = returnFunc(ctx, session, id)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// 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
// MockService_ViewRule_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ViewRule'
type MockService_ViewRule_Call struct {
*mock.Call
}
// ViewRule is a helper method to define mock.On call
// - ctx
// - session
// - id
func (_e *MockService_Expecter) ViewRule(ctx interface{}, session interface{}, id interface{}) *MockService_ViewRule_Call {
return &MockService_ViewRule_Call{Call: _e.mock.On("ViewRule", ctx, session, id)}
}
func (_c *MockService_ViewRule_Call) Run(run func(ctx context.Context, session authn.Session, id string)) *MockService_ViewRule_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context), args[1].(authn.Session), args[2].(string))
})
return _c
}
func (_c *MockService_ViewRule_Call) Return(rule re.Rule, err error) *MockService_ViewRule_Call {
_c.Call.Return(rule, err)
return _c
}
func (_c *MockService_ViewRule_Call) RunAndReturn(run func(ctx context.Context, session authn.Session, id string) (re.Rule, error)) *MockService_ViewRule_Call {
_c.Call.Return(run)
return _c
}
+102 -40
View File
@@ -1,55 +1,117 @@
// Code generated by mockery v2.53.3. DO NOT EDIT.
// Code generated by mockery; DO NOT EDIT.
// github.com/vektra/mockery
// template: testify
// Copyright (c) Abstract Machines
package mocks
package re
import (
mock "github.com/stretchr/testify/mock"
"time"
time "time"
mock "github.com/stretchr/testify/mock"
)
// Ticker is an autogenerated mock type for the Ticker type
type Ticker struct {
mock.Mock
}
// Stop provides a mock function with no fields
func (_m *Ticker) Stop() {
_m.Called()
}
// Tick provides a mock function with no fields
func (_m *Ticker) Tick() <-chan time.Time {
ret := _m.Called()
if len(ret) == 0 {
panic("no return value specified for Tick")
}
var r0 <-chan time.Time
if rf, ok := ret.Get(0).(func() <-chan time.Time); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(<-chan time.Time)
}
}
return r0
}
// NewTicker creates a new instance of Ticker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// NewMockTicker creates a new instance of MockTicker. 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 NewTicker(t interface {
func NewMockTicker(t interface {
mock.TestingT
Cleanup(func())
}) *Ticker {
mock := &Ticker{}
}) *MockTicker {
mock := &MockTicker{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}
// MockTicker is an autogenerated mock type for the Ticker type
type MockTicker struct {
mock.Mock
}
type MockTicker_Expecter struct {
mock *mock.Mock
}
func (_m *MockTicker) EXPECT() *MockTicker_Expecter {
return &MockTicker_Expecter{mock: &_m.Mock}
}
// Stop provides a mock function for the type MockTicker
func (_mock *MockTicker) Stop() {
_mock.Called()
return
}
// MockTicker_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop'
type MockTicker_Stop_Call struct {
*mock.Call
}
// Stop is a helper method to define mock.On call
func (_e *MockTicker_Expecter) Stop() *MockTicker_Stop_Call {
return &MockTicker_Stop_Call{Call: _e.mock.On("Stop")}
}
func (_c *MockTicker_Stop_Call) Run(run func()) *MockTicker_Stop_Call {
_c.Call.Run(func(args mock.Arguments) {
run()
})
return _c
}
func (_c *MockTicker_Stop_Call) Return() *MockTicker_Stop_Call {
_c.Call.Return()
return _c
}
func (_c *MockTicker_Stop_Call) RunAndReturn(run func()) *MockTicker_Stop_Call {
_c.Run(run)
return _c
}
// Tick provides a mock function for the type MockTicker
func (_mock *MockTicker) Tick() <-chan time.Time {
ret := _mock.Called()
if len(ret) == 0 {
panic("no return value specified for Tick")
}
var r0 <-chan time.Time
if returnFunc, ok := ret.Get(0).(func() <-chan time.Time); ok {
r0 = returnFunc()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(<-chan time.Time)
}
}
return r0
}
// MockTicker_Tick_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Tick'
type MockTicker_Tick_Call struct {
*mock.Call
}
// Tick is a helper method to define mock.On call
func (_e *MockTicker_Expecter) Tick() *MockTicker_Tick_Call {
return &MockTicker_Tick_Call{Call: _e.mock.On("Tick")}
}
func (_c *MockTicker_Tick_Call) Run(run func()) *MockTicker_Tick_Call {
_c.Call.Run(func(args mock.Arguments) {
run()
})
return _c
}
func (_c *MockTicker_Tick_Call) Return(timeCh <-chan time.Time) *MockTicker_Tick_Call {
_c.Call.Return(timeCh)
return _c
}
func (_c *MockTicker_Tick_Call) RunAndReturn(run func() <-chan time.Time) *MockTicker_Tick_Call {
_c.Call.Return(run)
return _c
}
-2
View File
@@ -52,7 +52,6 @@ type Rule struct {
UpdatedBy string `json:"updated_by,omitempty"`
}
//go:generate mockery --name Repository --output=./mocks --filename repo.go --quiet --note "Copyright (c) Abstract Machines"
type Repository interface {
AddRule(ctx context.Context, r Rule) (Rule, error)
ViewRule(ctx context.Context, id string) (Rule, error)
@@ -83,7 +82,6 @@ type Page struct {
Rules []Rule `json:"rules"`
}
//go:generate mockery --name Service --output=./mocks --filename service.go --quiet --note "Copyright (c) Abstract Machines"
type Service interface {
consumers.AsyncConsumer
AddRule(ctx context.Context, session authn.Session, r Rule) (Rule, error)
+4 -4
View File
@@ -12,7 +12,7 @@ import (
"github.com/0x6flab/namegenerator"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/re"
"github.com/absmach/magistrala/re/mocks"
mocks "github.com/absmach/magistrala/re/mocks"
"github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/errors"
repoerr "github.com/absmach/supermq/pkg/errors/repository"
@@ -57,9 +57,9 @@ var (
}
)
func newService(t *testing.T) (re.Service, *mocks.Repository, *pubsubmocks.PubSub, *mocks.Ticker) {
repo := new(mocks.Repository)
mockTicker := new(mocks.Ticker)
func newService(t *testing.T) (re.Service, *mocks.MockRepository, *pubsubmocks.PubSub, *mocks.MockTicker) {
repo := new(mocks.MockRepository)
mockTicker := new(mocks.MockTicker)
idProvider := uuid.NewMock()
pubsub := pubsubmocks.NewPubSub(t)
return re.NewService(repo, idProvider, pubsub, mockTicker), repo, pubsub, mockTicker
-1
View File
@@ -5,7 +5,6 @@ package re
import "time"
//go:generate mockery --name Ticker --output=./mocks --filename ticker.go --quiet --note "Copyright (c) Abstract Machines"
type Ticker interface {
Tick() <-chan time.Time
Stop()
+1 -1
View File
@@ -38,7 +38,7 @@ default values.
## Deployment
The service itself is distributed as Docker container. Check the [`postgres-reader`](https://github.com/absmach/supermq/blob/main/docker/addons/postgres-reader/docker-compose.yml#L17-L41) service section in
The service itself is distributed as Docker container. Check the [`postgres-reader`](https://github.com/absmach/supermq/blob/main/docker/addons/postgres-reader/docker-compose.yaml#L17-L41) service section in
docker-compose file to see how service is deployed.
To start the service, execute the following shell script:
+1 -1
View File
@@ -38,7 +38,7 @@ default values.
## Deployment
The service itself is distributed as Docker container. Check the [`timescale-reader`](https://github.com/absmach/supermq/blob/main/docker/addons/timescale-reader/docker-compose.yml#L17-L41) service section in docker-compose file to see how service is deployed.
The service itself is distributed as Docker container. Check the [`timescale-reader`](https://github.com/absmach/supermq/blob/main/docker/addons/timescale-reader/docker-compose.yaml#L17-L41) service section in docker-compose file to see how service is deployed.
To start the service, execute the following shell script:
+44
View File
@@ -13,3 +13,47 @@ packages:
dir: "./pkg/sdk/mocks"
mockname: "SDK"
filename: "sdk.go"
github.com/absmach/magistrala/re:
interfaces:
Repository:
config:
dir: "./re/mocks"
filename: "repository.go"
Service:
config:
dir: "./re/mocks"
filename: "service.go"
Ticker:
config:
dir: "./re/mocks"
filename: "ticker.go"
github.com/absmach/magistrala/bootstrap:
interfaces:
ConfigRepository:
config:
dir: "./bootstrap/mocks"
filename: "repository.go"
ConfigReader:
config:
dir: "./bootstrap/mocks"
filename: "reader.go"
Service:
config:
dir: "./bootstrap/mocks"
filename: "service.go"
github.com/absmach/magistrala/consumers/notifiers:
interfaces:
Service:
config:
dir: "./consumers/notifiers/mocks"
filename: "service.go"
SubscriptionsRepository:
config:
dir: "./consumers/notifiers/mocks"
filename: "repository.go"
github.com/absmach/magistrala/provision:
interfaces:
Service:
config:
dir: "./provision/mocks"
filename: "service.go"