Skip to content

Latest commit

 

History

History
55 lines (45 loc) · 2.74 KB

README.md

File metadata and controls

55 lines (45 loc) · 2.74 KB

Generating Mock Files Using Mockery

Introduction

This document explains how the mock files for our Go application were generated using the mockery tool. It provides the commands used and addresses whether this task is a unique occurrence or a recurring one. It also formalizes the commands for future reference.

Overview of Mockery

Mockery is a tool used to automatically generate mock implementations of interfaces in Go. These mocks are typically used in unit tests to simulate the behavior of real objects and isolate the functionality being tested.

Commands Used to Generate Mock Files

The following commands were used to generate the mock files for different packages in our Go application. Each command navigates to a specific directory and then uses mockery to generate mock files for all interfaces in that directory.

Command for proxy/iface Package

cd proxy/iface
mockery --all --output=../../mocks/proxy/iface --outpkg=mocks
  • Description: Generates mock files for all interfaces in the proxy/iface package.
  • Output Directory: ../../mocks/proxy/iface
  • Output Package: mocks

Command for otel Package

cd otel
mockery --all --output=../mocks/otel --outpkg=mocks
  • Description: Generates mock files for all interfaces in the otel package.
  • Output Directory: ../mocks/otel
  • Output Package: mocks

Command for proxy Package

cd proxy
mockery --all --output=../mocks/proxy --outpkg=mocks
  • Description: Generates mock files for all interfaces in the proxy package.
  • Output Directory: ../mocks/proxy
  • Output Package: mocks

Command for spanner Package

cd spanner
mockery --all --output=../mocks/spanner --outpkg=mocks
  • Description: Generates mock files for all interfaces in the spanner package.
  • Output Directory: ../mocks/spanner
  • Output Package: mocks

Frequency of Task

This task is generally a recurring task. Mock files should be regenerated whenever there are changes to the interfaces in the respective packages. It's advisable to review and regenerate mock files at regular intervals, such as once every six months, or whenever significant changes are made to the interfaces.

Future Reference

For future reference, the commands provided above should be used to regenerate mock files. Ensure to navigate to the appropriate directories and execute the commands to maintain consistency in the structure and location of mock files.

Conclusion

This document serves as a formal record of the commands used to generate mock files for our Go application using the mockery tool. By following the outlined commands and maintaining a regular schedule for regenerating mock files, we can ensure that our unit tests remain up-to-date and effective.