From 11f28d4867a16d7c1b068235f1563f6efa62cc5c Mon Sep 17 00:00:00 2001 From: Landon Clipp <11232769+LandonTClipp@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:34:40 -0600 Subject: [PATCH] v3: Rename styles of mocks to be less confusing (#900) When talking about mockery in-person, I noticed it's hard to differentiate "mockery mocks" from "moq mocks". This change disambiguates the different styles by giving them phonetically different sounds. --- .mockery.yml | 2 +- .mockery_moq.yml | 4 ++-- Taskfile.yml | 2 +- docs/{template-moq.md => template-matryer.md} | 8 ++++---- docs/{template-mockery.md => template-testify.md} | 6 +++--- docs/templates.md | 8 ++++---- internal/{moq.templ => mock_matryer.templ} | 0 internal/{mockery.templ => mock_testify.templ} | 0 internal/template_generator.go | 12 ++++++------ mkdocs.yml | 4 ++-- 10 files changed, 23 insertions(+), 23 deletions(-) rename docs/{template-moq.md => template-matryer.md} (96%) rename docs/{template-mockery.md => template-testify.md} (99%) rename internal/{moq.templ => mock_matryer.templ} (100%) rename internal/{mockery.templ => mock_testify.templ} (100%) diff --git a/.mockery.yml b/.mockery.yml index b64f8579..b83b58a0 100644 --- a/.mockery.yml +++ b/.mockery.yml @@ -1,4 +1,4 @@ -template: "mockery" +template: "testify" tags: "custom2" formatter: "goimports" all: True diff --git a/.mockery_moq.yml b/.mockery_moq.yml index ddec3e64..899a61c9 100644 --- a/.mockery_moq.yml +++ b/.mockery_moq.yml @@ -1,6 +1,6 @@ -template: moq +template: matryer mockname: "Moq{{.InterfaceName}}" -filename: "mocks_moq_test.go" +filename: "mocks_matryer_test.go" all: true template-data: skip-ensure: False diff --git a/Taskfile.yml b/Taskfile.yml index 065b303d..7c8cf32c 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -21,7 +21,7 @@ tasks: mocks.remove: desc: remove all mock files cmds: - - find . -name '*_mock.go' -o -name 'mock_*_test.go' -o -name 'mocks.go' -o -name "mocks_moq.go" -o -name 'mocks_test.go' -o -name 'mocks_moq_test.go' -o -name 'mocks_*_test.go' | xargs -r rm + - find . -name '*_mock.go' -o -name 'mock_*_test.go' -o -name 'mocks.go' -o -name "mocks_moq.go" -o -name 'mocks_test.go' -o -name 'mocks_*_test.go' | xargs -r rm - rm -rf mocks/ mocks.generate.mockery: diff --git a/docs/template-moq.md b/docs/template-matryer.md similarity index 96% rename from docs/template-moq.md rename to docs/template-matryer.md index b85be1c4..1566898e 100644 --- a/docs/template-moq.md +++ b/docs/template-matryer.md @@ -1,8 +1,8 @@ --- -title: Moq +title: matryer --- -Moq +matryer/moq ==== @@ -21,7 +21,7 @@ Moq === "`.mockery.yml`" ```yaml - template: moq + template: matryer packages: github.com/vektra/mockery/v3/pkg/fixtures: config: @@ -112,7 +112,7 @@ Moq } ``` -Moq-style mocks are far simpler, and probably more intuitive, than mockery-style mocks. All that's needed is to define the function that will be run when the mock's method is called. +Moq-style mocks are far simpler, and probably more intuitive, than testify-style mocks. All that's needed is to define the function that will be run when the mock's method is called. ## `template-data` diff --git a/docs/template-mockery.md b/docs/template-testify.md similarity index 99% rename from docs/template-mockery.md rename to docs/template-testify.md index 85688162..67c92e53 100644 --- a/docs/template-mockery.md +++ b/docs/template-testify.md @@ -1,11 +1,11 @@ --- -title: Mockery +title: testify --- Mockery ======= -Features for `#!yaml template: mockery`. +Features for `#!yaml template: testify`. Choosing this template will render a traditional "mockery-style" template. The section below shows what will be rendered for the given interface. @@ -25,7 +25,7 @@ section below shows what will be rendered for the given interface. === "`.mockery.yml`" ```yaml - template: mockery + template: testify packages: github.com/vektra/mockery/v3/pkg/fixtures: config: diff --git a/docs/templates.md b/docs/templates.md index 66f8bc1c..3ed74359 100644 --- a/docs/templates.md +++ b/docs/templates.md @@ -6,9 +6,9 @@ templates that you can select with the `#!yaml template:` config parameter. ## Template Options -### `#!yaml template: "mockery"` +### `#!yaml template: "testify"` -[`mockery`](template-mockery.md) templates generate powerful, testify-based mock objects. They allow you to create expectations using argument-to-return-value matching logic. +[`testify`](template-testify.md) templates generate powerful, testify-based mock objects. They allow you to create expectations using argument-to-return-value matching logic. ```go package test @@ -28,9 +28,9 @@ func TestRequesterMock(t *testing.T) { } ``` -### `#!yaml template: "moq"` +### `#!yaml template: "matryer"` -[`moq`](template-moq.md) templates draw from the mocks generated from the project at https://github.com/matryer/moq. This project was folded into mockery, and thus moq-style mocks can be natively generated from within mockery. +[`matryer`](template-matryer.md) templates draw from the mocks generated from the project at https://github.com/matryer/moq. This project was folded into mockery, and thus moq-style mocks can be natively generated from within mockery. Mocks generated using this template allow you to define precise functions to be run. Example: diff --git a/internal/moq.templ b/internal/mock_matryer.templ similarity index 100% rename from internal/moq.templ rename to internal/mock_matryer.templ diff --git a/internal/mockery.templ b/internal/mock_testify.templ similarity index 100% rename from internal/mockery.templ rename to internal/mock_testify.templ diff --git a/internal/template_generator.go b/internal/template_generator.go index 93fd228c..69ba172c 100644 --- a/internal/template_generator.go +++ b/internal/template_generator.go @@ -30,15 +30,15 @@ const ( ) var ( - //go:embed moq.templ - templateMoq string - //go:embed mockery.templ - templateMockery string + //go:embed mock_matryer.templ + templateMatryer string + //go:embed mock_testify.templ + templateTestify string ) var styleTemplates = map[string]string{ - "moq": templateMoq, - "mockery": templateMockery, + "matryer": templateMatryer, + "testify": templateTestify, } // findPkgPath returns the fully-qualified go import path of a given dir. The diff --git a/mkdocs.yml b/mkdocs.yml index 0985f459..3ee42fb3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -63,8 +63,8 @@ nav: - Templates: templates.md - Running: running.md - Templates: - - template-mockery.md - - template-moq.md + - template-testify.md + - template-matryer.md - Features: - replace-type.md - Notes: