Skip to content

Commit

Permalink
Add make command for mockery
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewgdewar committed Nov 15, 2024
1 parent 5b46580 commit 57dcd92
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ Containerfile
compose_files/pulp/pulp-oci-images

#config
configs/config.yaml
configs/config.yaml

#mockery binaries
bin
11 changes: 11 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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": []
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.mergeEditor": false
}
1 change: 1 addition & 0 deletions mk/includes.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ include mk/variables.mk
include mk/compose.mk
include mk/help.mk
include mk/test.mk
include mk/mockery.mk
17 changes: 17 additions & 0 deletions mk/mockery.mk
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion pkg/tangy/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
39 changes: 38 additions & 1 deletion pkg/tangy/tangy_mock.go

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

0 comments on commit 57dcd92

Please sign in to comment.