shared

package
v0.0.0-...-2b706d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugMode

func DebugMode(c *ClientFactory)

DebugMode is an example of defining a functional options helper

func SetVersion

func SetVersion(version string) func(c *ClientFactory)

SetVersion is a functional option that sets the Cli version that the API Client references Learn more: https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

Types

type ClientFactory

type ClientFactory struct {
	API          func() api.APIInterface
	AppClient    func() *app.Client
	Auth         func() auth.AuthInterface
	CLIVersion   string
	Config       *config.Config
	EventTracker tracking.TrackingManager
	HookExecutor hooks.HookExecutor
	IO           iostreams.IOStreamer
	Runtime      runtime.Runtime
	SDKConfig    hooks.SDKCLIConfig

	// Browser can display or open URLs as webpages on the internet
	Browser func() slackdeps.Browser

	// Fs is the file system module that's shared by all packages and enables testing & mock of the file system
	Fs afero.Fs

	// Os are a group of operating system functions following the `os` interface that are shared by all packages and enables testing & mocking
	Os types.Os

	// CleanupWaitGroup is a group of wait groups shared by all packages and allow functions to cleanup before the process terminates
	CleanupWaitGroup sync.WaitGroup
}

ClientFactory are shared clients and configurations for use across the CLI commands (cmd) and handlers (pkg).

func NewClientFactory

func NewClientFactory(options ...func(*ClientFactory)) *ClientFactory

NewClientFactory creates a new ClientFactory type with the default function handlers

func (*ClientFactory) InitRuntime

func (c *ClientFactory) InitRuntime(ctx context.Context, dirPath string) error

InitRuntime initializes a new Runtime instance from the runtime flag or the SDK config or the directory structure

func (*ClientFactory) InitSDKConfig

func (c *ClientFactory) InitSDKConfig(ctx context.Context, dirPath string) error

InitSDKConfig finds and loads hook configurations for a project

func (*ClientFactory) InitSDKConfigFromJSON

func (c *ClientFactory) InitSDKConfigFromJSON(ctx context.Context, configFileBytes []byte) error

InitSDKConfigFromJSON merges configuration values from the `get-hooks` hook and the local configuration file

type ClientsMock

type ClientsMock struct {
	mock.Mock
	API          *api.APIMock
	Auth         *auth.AuthMock
	AppClient    *app.Client
	Browser      *slackdeps.BrowserMock
	Config       *config.Config
	EventTracker *tracking.EventTrackerMock
	Fs           *slackdeps.FsMock
	IO           *iostreams.IOStreamsMock
	Os           *slackdeps.OsMock
	Stdout       *bytes.Buffer
	HookExecutor hooks.MockHookExecutor
}

ClientsMock defines mocks that will override aspects of clients for testing purposes.

func NewClientsMock

func NewClientsMock() *ClientsMock

NewClientsMock will create a new ClientsMock that is ready to be applied to an existing clients with .MockClientFactory().

func (*ClientsMock) AddDefaultMocks

func (m *ClientsMock) AddDefaultMocks()

AddDefaultMocks installs the default mock actions to fallback on.

func (*ClientsMock) GetCombinedOutput

func (m *ClientsMock) GetCombinedOutput() string

GetCombinedOutput is a helper method to return the combined output of stdout and stderr for testing.

func (*ClientsMock) GetStderrOutput

func (m *ClientsMock) GetStderrOutput() string

GetStderrOutput is a helper method to return the stderr output for testing.

func (*ClientsMock) GetStdoutOutput

func (m *ClientsMock) GetStdoutOutput() string

GetStdoutOutput is a helper method to return the stdout output for testing.

func (*ClientsMock) MockClientFactory

func (m *ClientsMock) MockClientFactory() func(c *ClientFactory)

MockClientFactory is a functional option that installs mocks into a clients instance. Learn more: https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL