Skip to content

Commit f0d2548

Browse files
authored
chore: add mockery to generate mocks (#178)
Adds Mockery to the project for generating mocks of interfaces. This also adds a new task `task gen:mocks` to help with the generation process.
1 parent f5a2ca9 commit f0d2548

File tree

6 files changed

+38
-2
lines changed

6 files changed

+38
-2
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,16 @@ go.work
1919
go.work.sum
2020

2121
# Editor config directories
22+
## IntelliJ IDEA
2223
.idea/
24+
25+
## Visual Studio Code
2326
.vscode/
27+
28+
# Node.js dependencies
2429
node_modules/
30+
31+
# Log output
2532
*.log
2633

2734
# OS generated files

.mockery.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
all: false
2+
dir: '{{.InterfaceDir}}'
3+
filename: "mocks_test.go"
4+
force-file-write: true
5+
formatter: goimports
6+
log-level: info
7+
structname: '{{.Mock}}{{.InterfaceName}}'
8+
pkgname: '{{.SrcPackageName}}'
9+
recursive: false
10+
require-template-schema-exists: true
11+
template: testify
12+
template-schema: '{{.Template}}.schema.json'
13+
packages:
14+
#github.com/smartcontractkit/chainlink-deployments-framework/...

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
golang 1.24.1
22
golangci-lint 2.1.6
3+
mockery 3.3.4
34
nodejs 20.16.0
45
pnpm 10.6.5
56
task 3.41.0
6-

Taskfile.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
version: "3"
44

55
includes:
6+
generate:
7+
taskfile: ./taskfiles/generate/Taskfile.yml
8+
aliases: [gen]
9+
610
lint:
711
taskfile: ./taskfiles/lint/Taskfile.yml
812

taskfiles/generate/Taskfile.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://taskfile.dev
2+
#
3+
# Handles code generation tasks
4+
5+
version: "3"
6+
7+
tasks:
8+
mocks:
9+
desc: Generate mocks for interfaces
10+
cmds:
11+
- mockery

taskfiles/lint/taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ tasks:
1414
fix:
1515
desc: Runs the linter in fix mode
1616
cmds:
17-
- golangci-lint run --fix
17+
- golangci-lint run --fix

0 commit comments

Comments
 (0)