vektra / mockery

A mock code autogenerator for Go
https://vektra.github.io/mockery/
BSD 3-Clause "New" or "Revised" License
5.8k stars 395 forks source link

Files being created even with `dry-run: true` #769

Closed danielleallopez closed 4 days ago

danielleallopez commented 3 months ago

PLEASE READ

DO NOT submit tickets without first using the latest version of Golang, clearing your local golang package cache, and re-building mockery using the latest Golang version and the latest version of mockery. Please provide evidence this has been done in your issue. Failure to provide this evidence will likely result in your issue being closed.

Description

Running mockery with dry-run: true creates files instead of only printing logs

Mockery Version

2.42.1

Golang Version

1.22.0

NOTE: Please upgrade to the latest golang version before submitting tickets!

Installation Method

Steps to Reproduce

  1. Create .mockery.yaml config file with dry-run: true
    dir: "test/mocks"
    outpkg: "mocks"
    filename: "{{.InterfaceName | snakecase}}.go"
    mockname: "{{.InterfaceName}}"
    inpackage: false
    testonly: false
    with-expecter: true
    keeptree: false
    dry-run: true
    packages:
    github.com/mycompany/internal:
    config:
      all: true
      recursive: true
  2. Run mockery on same folder

Expected Behavior

Logs are printed, showing which files would be created

Actual Behavior

Files are actually created

19 Mar 24 11:44 CET INF generating mocks for interface dry-run=true interface=foo qualified-name=github.com/mycompany/internal version=v2.42.1
19 Mar 24 11:44 CET INF writing to file dry-run=true file=test/mocks/foo.go interface=foo qualified-name=github.com/mycompany/internal version=v2.42.1
LandonTClipp commented 3 months ago

This may have been a regression when I rolled out packages, should be an easy fix.