Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/GoogleCloudPlatform/compute-image-tools/cli_tools

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/GoogleCloudPlatform/compute-image-tools/cli_tools

  • v0.0.0-20241218215311-fa94ed05a4c5
  • Source
  • Go
  • Socket score

Version published
Created
Source

cli_tools uses gomock. The mocks are stored as source code, and need to be updated whenever the referenced interface is changed.

Setup

To use existing mocks, no setup is required.

To generate new mocks, or update existing mocks, you need the mockgen tool:

go install github.com/golang/mock/mockgen
export PATH=$PATH:~/go/bin

Example: Updating mocks with go generate

For interfaces within cli_tools that require mocking, we create go generate definitions. These definitions codify naming convention, and simplify future updates.

For example, to update the mock for shell.Executor:

cd cli_tools/common/utils/shell
go generate ./...

Example: Update external mocks

For interfaces that are external to cli_tools, we run mockgen directly.

For example, to update the mock for daisy.Logger:

cd cli_tools/mocks
mockgen -package mocks -mock_names Logger=MockDaisyLogger \
  github.com/GoogleCloudPlatform/compute-daisy Logger  > mock_daisy_logger.go

Tips:

  1. The headers of existing mocks typically include the package and interface names required to generate mocks.
  2. To avoid namespace clashing, it may be required to use the -mock_names flag. Executing git diff will help you to determine whether that flag is required.

Best Practices

  • If the mock will be used throughout *cli_tools, consider creating it in cli_tools/mocks.
  • If the mock is used in a single place (to test a particular component), consider creating it near that component. For example: cli_tools/common/image/importer/mocks/source_mocks.go

FAQs

Package last updated on 18 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc