From 57dcd92bb08998886b371aac982a7d96b61058a2 Mon Sep 17 00:00:00 2001 From: Andrew Dewar Date: Fri, 15 Nov 2024 12:59:44 -0500 Subject: [PATCH] Add make command for mockery --- .gitignore | 5 ++++- .mockery.yaml | 11 +++++++++++ .vscode/launch.json | 7 +++++++ .vscode/settings.json | 3 +++ mk/includes.mk | 1 + mk/mockery.mk | 17 +++++++++++++++++ pkg/tangy/interface.go | 1 - pkg/tangy/tangy_mock.go | 39 ++++++++++++++++++++++++++++++++++++++- 8 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 .mockery.yaml create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 mk/mockery.mk diff --git a/.gitignore b/.gitignore index 436757f..38ffdad 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,7 @@ Containerfile compose_files/pulp/pulp-oci-images #config -configs/config.yaml \ No newline at end of file +configs/config.yaml + +#mockery binaries +bin diff --git a/.mockery.yaml b/.mockery.yaml new file mode 100644 index 0000000..7d5ad89 --- /dev/null +++ b/.mockery.yaml @@ -0,0 +1,11 @@ +with-expecter: false +inpackage: True +dir: "./pkg/tangy" +mockname: "Mock{{.InterfaceName}}" +outpkg: "{{.PackageName}}" +filename: "{{.InterfaceName}}_mock.go" +all: True +packages: + github.com/content-services/tang: + config: + recursive: True diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..1b8aa88 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,7 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f25ce44 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.mergeEditor": false +} diff --git a/mk/includes.mk b/mk/includes.mk index afe2d9c..75b1f8b 100644 --- a/mk/includes.mk +++ b/mk/includes.mk @@ -22,3 +22,4 @@ include mk/variables.mk include mk/compose.mk include mk/help.mk include mk/test.mk +include mk/mockery.mk diff --git a/mk/mockery.mk b/mk/mockery.mk new file mode 100644 index 0000000..5d8ded7 --- /dev/null +++ b/mk/mockery.mk @@ -0,0 +1,17 @@ +## +# Set of rules to manage podman-compose +# +# Requires 'mk/variables.mk' +## + +MOCKERY_VERSION := $(shell curl -L https://api.github.com/repos/vektra/mockery/releases/latest | jq --raw-output .tag_name | sed 's/^v//') + +GO_OUTPUT ?= $(PROJECT_DIR)/bin + +$(GO_OUTPUT)/mockery: ## Install mockery locally on your GO_OUTPUT (./release) directory + mkdir -p $(GO_OUTPUT) && \ + curl -sSfL https://github.com/vektra/mockery/releases/download/v$(MOCKERY_VERSION)/mockery_$(MOCKERY_VERSION)_$(shell uname -s)_$(shell uname -m).tar.gz | tar -xz -C $(GO_OUTPUT) mockery + +.PHONY: mock ## Run mockery +mock: $(GO_OUTPUT)/mockery ## Install mockery if it isn't already in ./release directory and regenerate mocks + $(GO_OUTPUT)/mockery diff --git a/pkg/tangy/interface.go b/pkg/tangy/interface.go index bafc5f2..be8c44a 100644 --- a/pkg/tangy/interface.go +++ b/pkg/tangy/interface.go @@ -50,7 +50,6 @@ type tangyImpl struct { logger Logger } -//go:generate mockery --name Tangy --filename tangy_mock.go --inpackage type Tangy interface { RpmRepositoryVersionPackageSearch(ctx context.Context, hrefs []string, search string, limit int) ([]RpmPackageSearch, error) RpmRepositoryVersionPackageGroupSearch(ctx context.Context, hrefs []string, search string, limit int) ([]RpmPackageGroupSearch, error) diff --git a/pkg/tangy/tangy_mock.go b/pkg/tangy/tangy_mock.go index e3fad77..aff776a 100644 --- a/pkg/tangy/tangy_mock.go +++ b/pkg/tangy/tangy_mock.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.2. DO NOT EDIT. +// Code generated by mockery v2.47.0. DO NOT EDIT. package tangy @@ -85,6 +85,43 @@ func (_m *MockTangy) RpmRepositoryVersionErrataList(ctx context.Context, hrefs [ return r0, r1, r2 } +// RpmRepositoryVersionModuleStreams provides a mock function with given fields: ctx, hrefs, rpmNames, search, pageOpts +func (_m *MockTangy) RpmRepositoryVersionModuleStreams(ctx context.Context, hrefs []string, rpmNames []string, search string, pageOpts PageOptions) ([]ModuleStreams, int, error) { + ret := _m.Called(ctx, hrefs, rpmNames, search, pageOpts) + + if len(ret) == 0 { + panic("no return value specified for RpmRepositoryVersionModuleStreams") + } + + var r0 []ModuleStreams + var r1 int + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, []string, []string, string, PageOptions) ([]ModuleStreams, int, error)); ok { + return rf(ctx, hrefs, rpmNames, search, pageOpts) + } + if rf, ok := ret.Get(0).(func(context.Context, []string, []string, string, PageOptions) []ModuleStreams); ok { + r0 = rf(ctx, hrefs, rpmNames, search, pageOpts) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]ModuleStreams) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []string, []string, string, PageOptions) int); ok { + r1 = rf(ctx, hrefs, rpmNames, search, pageOpts) + } else { + r1 = ret.Get(1).(int) + } + + if rf, ok := ret.Get(2).(func(context.Context, []string, []string, string, PageOptions) error); ok { + r2 = rf(ctx, hrefs, rpmNames, search, pageOpts) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + // RpmRepositoryVersionPackageGroupSearch provides a mock function with given fields: ctx, hrefs, search, limit func (_m *MockTangy) RpmRepositoryVersionPackageGroupSearch(ctx context.Context, hrefs []string, search string, limit int) ([]RpmPackageGroupSearch, error) { ret := _m.Called(ctx, hrefs, search, limit)