ghmock

package
v2.100.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigMock

type ConfigMock struct {
	// AccessibleColorsFunc mocks the AccessibleColors method.
	AccessibleColorsFunc func(hostname string) gh.ConfigEntry

	// AccessiblePrompterFunc mocks the AccessiblePrompter method.
	AccessiblePrompterFunc func(hostname string) gh.ConfigEntry

	// AliasesFunc mocks the Aliases method.
	AliasesFunc func() gh.AliasConfig

	// AuthenticationFunc mocks the Authentication method.
	AuthenticationFunc func() gh.AuthConfig

	// BrowserFunc mocks the Browser method.
	BrowserFunc func(hostname string) gh.ConfigEntry

	// CacheDirFunc mocks the CacheDir method.
	CacheDirFunc func() string

	// ColorLabelsFunc mocks the ColorLabels method.
	ColorLabelsFunc func(hostname string) gh.ConfigEntry

	// EditorFunc mocks the Editor method.
	EditorFunc func(hostname string) gh.ConfigEntry

	// GetOrDefaultFunc mocks the GetOrDefault method.
	GetOrDefaultFunc func(hostname string, key string) o.Option[gh.ConfigEntry]

	// GitProtocolFunc mocks the GitProtocol method.
	GitProtocolFunc func(hostname string) gh.ConfigEntry

	// HTTPUnixSocketFunc mocks the HTTPUnixSocket method.
	HTTPUnixSocketFunc func(hostname string) gh.ConfigEntry

	// MigrateFunc mocks the Migrate method.
	MigrateFunc func(migration gh.Migration) error

	// PagerFunc mocks the Pager method.
	PagerFunc func(hostname string) gh.ConfigEntry

	// PreferEditorPromptFunc mocks the PreferEditorPrompt method.
	PreferEditorPromptFunc func(hostname string) gh.ConfigEntry

	// PromptFunc mocks the Prompt method.
	PromptFunc func(hostname string) gh.ConfigEntry

	// SetFunc mocks the Set method.
	SetFunc func(hostname string, key string, value string)

	// SpinnerFunc mocks the Spinner method.
	SpinnerFunc func(hostname string) gh.ConfigEntry

	// TelemetryFunc mocks the Telemetry method.
	TelemetryFunc func() gh.ConfigEntry

	// VersionFunc mocks the Version method.
	VersionFunc func() o.Option[string]

	// WriteFunc mocks the Write method.
	WriteFunc func() error
	// contains filtered or unexported fields
}

ConfigMock is a mock implementation of gh.Config.

func TestSomethingThatUsesConfig(t *testing.T) {

	// make and configure a mocked gh.Config
	mockedConfig := &ConfigMock{
		AccessibleColorsFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the AccessibleColors method")
		},
		AccessiblePrompterFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the AccessiblePrompter method")
		},
		AliasesFunc: func() gh.AliasConfig {
			panic("mock out the Aliases method")
		},
		AuthenticationFunc: func() gh.AuthConfig {
			panic("mock out the Authentication method")
		},
		BrowserFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the Browser method")
		},
		CacheDirFunc: func() string {
			panic("mock out the CacheDir method")
		},
		ColorLabelsFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the ColorLabels method")
		},
		EditorFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the Editor method")
		},
		GetOrDefaultFunc: func(hostname string, key string) o.Option[gh.ConfigEntry] {
			panic("mock out the GetOrDefault method")
		},
		GitProtocolFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the GitProtocol method")
		},
		HTTPUnixSocketFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the HTTPUnixSocket method")
		},
		MigrateFunc: func(migration gh.Migration) error {
			panic("mock out the Migrate method")
		},
		PagerFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the Pager method")
		},
		PreferEditorPromptFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the PreferEditorPrompt method")
		},
		PromptFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the Prompt method")
		},
		SetFunc: func(hostname string, key string, value string)  {
			panic("mock out the Set method")
		},
		SpinnerFunc: func(hostname string) gh.ConfigEntry {
			panic("mock out the Spinner method")
		},
		TelemetryFunc: func() gh.ConfigEntry {
			panic("mock out the Telemetry method")
		},
		VersionFunc: func() o.Option[string] {
			panic("mock out the Version method")
		},
		WriteFunc: func() error {
			panic("mock out the Write method")
		},
	}

	// use mockedConfig in code that requires gh.Config
	// and then make assertions.

}

func (*ConfigMock) AccessibleColors added in v2.71.0

func (mock *ConfigMock) AccessibleColors(hostname string) gh.ConfigEntry

AccessibleColors calls AccessibleColorsFunc.

func (*ConfigMock) AccessibleColorsCalls added in v2.71.0

func (mock *ConfigMock) AccessibleColorsCalls() []struct {
	Hostname string
}

AccessibleColorsCalls gets all the calls that were made to AccessibleColors. Check the length with:

len(mockedConfig.AccessibleColorsCalls())

func (*ConfigMock) AccessiblePrompter added in v2.71.0

func (mock *ConfigMock) AccessiblePrompter(hostname string) gh.ConfigEntry

AccessiblePrompter calls AccessiblePrompterFunc.

func (*ConfigMock) AccessiblePrompterCalls added in v2.71.0

func (mock *ConfigMock) AccessiblePrompterCalls() []struct {
	Hostname string
}

AccessiblePrompterCalls gets all the calls that were made to AccessiblePrompter. Check the length with:

len(mockedConfig.AccessiblePrompterCalls())

func (*ConfigMock) Aliases

func (mock *ConfigMock) Aliases() gh.AliasConfig

Aliases calls AliasesFunc.

func (*ConfigMock) AliasesCalls

func (mock *ConfigMock) AliasesCalls() []struct {
}

AliasesCalls gets all the calls that were made to Aliases. Check the length with:

len(mockedConfig.AliasesCalls())

func (*ConfigMock) Authentication

func (mock *ConfigMock) Authentication() gh.AuthConfig

Authentication calls AuthenticationFunc.

func (*ConfigMock) AuthenticationCalls

func (mock *ConfigMock) AuthenticationCalls() []struct {
}

AuthenticationCalls gets all the calls that were made to Authentication. Check the length with:

len(mockedConfig.AuthenticationCalls())

func (*ConfigMock) Browser

func (mock *ConfigMock) Browser(hostname string) gh.ConfigEntry

Browser calls BrowserFunc.

func (*ConfigMock) BrowserCalls

func (mock *ConfigMock) BrowserCalls() []struct {
	Hostname string
}

BrowserCalls gets all the calls that were made to Browser. Check the length with:

len(mockedConfig.BrowserCalls())

func (*ConfigMock) CacheDir

func (mock *ConfigMock) CacheDir() string

CacheDir calls CacheDirFunc.

func (*ConfigMock) CacheDirCalls

func (mock *ConfigMock) CacheDirCalls() []struct {
}

CacheDirCalls gets all the calls that were made to CacheDir. Check the length with:

len(mockedConfig.CacheDirCalls())

func (*ConfigMock) ColorLabels added in v2.70.0

func (mock *ConfigMock) ColorLabels(hostname string) gh.ConfigEntry

ColorLabels calls ColorLabelsFunc.

func (*ConfigMock) ColorLabelsCalls added in v2.70.0

func (mock *ConfigMock) ColorLabelsCalls() []struct {
	Hostname string
}

ColorLabelsCalls gets all the calls that were made to ColorLabels. Check the length with:

len(mockedConfig.ColorLabelsCalls())

func (*ConfigMock) Editor

func (mock *ConfigMock) Editor(hostname string) gh.ConfigEntry

Editor calls EditorFunc.

func (*ConfigMock) EditorCalls

func (mock *ConfigMock) EditorCalls() []struct {
	Hostname string
}

EditorCalls gets all the calls that were made to Editor. Check the length with:

len(mockedConfig.EditorCalls())

func (*ConfigMock) GetOrDefault

func (mock *ConfigMock) GetOrDefault(hostname string, key string) o.Option[gh.ConfigEntry]

GetOrDefault calls GetOrDefaultFunc.

func (*ConfigMock) GetOrDefaultCalls

func (mock *ConfigMock) GetOrDefaultCalls() []struct {
	Hostname string
	Key      string
}

GetOrDefaultCalls gets all the calls that were made to GetOrDefault. Check the length with:

len(mockedConfig.GetOrDefaultCalls())

func (*ConfigMock) GitProtocol

func (mock *ConfigMock) GitProtocol(hostname string) gh.ConfigEntry

GitProtocol calls GitProtocolFunc.

func (*ConfigMock) GitProtocolCalls

func (mock *ConfigMock) GitProtocolCalls() []struct {
	Hostname string
}

GitProtocolCalls gets all the calls that were made to GitProtocol. Check the length with:

len(mockedConfig.GitProtocolCalls())

func (*ConfigMock) HTTPUnixSocket

func (mock *ConfigMock) HTTPUnixSocket(hostname string) gh.ConfigEntry

HTTPUnixSocket calls HTTPUnixSocketFunc.

func (*ConfigMock) HTTPUnixSocketCalls

func (mock *ConfigMock) HTTPUnixSocketCalls() []struct {
	Hostname string
}

HTTPUnixSocketCalls gets all the calls that were made to HTTPUnixSocket. Check the length with:

len(mockedConfig.HTTPUnixSocketCalls())

func (*ConfigMock) Migrate

func (mock *ConfigMock) Migrate(migration gh.Migration) error

Migrate calls MigrateFunc.

func (*ConfigMock) MigrateCalls

func (mock *ConfigMock) MigrateCalls() []struct {
	Migration gh.Migration
}

MigrateCalls gets all the calls that were made to Migrate. Check the length with:

len(mockedConfig.MigrateCalls())

func (*ConfigMock) Pager

func (mock *ConfigMock) Pager(hostname string) gh.ConfigEntry

Pager calls PagerFunc.

func (*ConfigMock) PagerCalls

func (mock *ConfigMock) PagerCalls() []struct {
	Hostname string
}

PagerCalls gets all the calls that were made to Pager. Check the length with:

len(mockedConfig.PagerCalls())

func (*ConfigMock) PreferEditorPrompt added in v2.53.0

func (mock *ConfigMock) PreferEditorPrompt(hostname string) gh.ConfigEntry

PreferEditorPrompt calls PreferEditorPromptFunc.

func (*ConfigMock) PreferEditorPromptCalls added in v2.53.0

func (mock *ConfigMock) PreferEditorPromptCalls() []struct {
	Hostname string
}

PreferEditorPromptCalls gets all the calls that were made to PreferEditorPrompt. Check the length with:

len(mockedConfig.PreferEditorPromptCalls())

func (*ConfigMock) Prompt

func (mock *ConfigMock) Prompt(hostname string) gh.ConfigEntry

Prompt calls PromptFunc.

func (*ConfigMock) PromptCalls

func (mock *ConfigMock) PromptCalls() []struct {
	Hostname string
}

PromptCalls gets all the calls that were made to Prompt. Check the length with:

len(mockedConfig.PromptCalls())

func (*ConfigMock) Set

func (mock *ConfigMock) Set(hostname string, key string, value string)

Set calls SetFunc.

func (*ConfigMock) SetCalls

func (mock *ConfigMock) SetCalls() []struct {
	Hostname string
	Key      string
	Value    string
}

SetCalls gets all the calls that were made to Set. Check the length with:

len(mockedConfig.SetCalls())

func (*ConfigMock) Spinner added in v2.71.0

func (mock *ConfigMock) Spinner(hostname string) gh.ConfigEntry

Spinner calls SpinnerFunc.

func (*ConfigMock) SpinnerCalls added in v2.71.0

func (mock *ConfigMock) SpinnerCalls() []struct {
	Hostname string
}

SpinnerCalls gets all the calls that were made to Spinner. Check the length with:

len(mockedConfig.SpinnerCalls())

func (*ConfigMock) Telemetry added in v2.91.0

func (mock *ConfigMock) Telemetry() gh.ConfigEntry

Telemetry calls TelemetryFunc.

func (*ConfigMock) TelemetryCalls added in v2.91.0

func (mock *ConfigMock) TelemetryCalls() []struct {
}

TelemetryCalls gets all the calls that were made to Telemetry. Check the length with:

len(mockedConfig.TelemetryCalls())

func (*ConfigMock) Version

func (mock *ConfigMock) Version() o.Option[string]

Version calls VersionFunc.

func (*ConfigMock) VersionCalls

func (mock *ConfigMock) VersionCalls() []struct {
}

VersionCalls gets all the calls that were made to Version. Check the length with:

len(mockedConfig.VersionCalls())

func (*ConfigMock) Write

func (mock *ConfigMock) Write() error

Write calls WriteFunc.

func (*ConfigMock) WriteCalls

func (mock *ConfigMock) WriteCalls() []struct {
}

WriteCalls gets all the calls that were made to Write. Check the length with:

len(mockedConfig.WriteCalls())

type MigrationMock

type MigrationMock struct {
	// DoFunc mocks the Do method.
	DoFunc func(config *ghConfig.Config) error

	// PostVersionFunc mocks the PostVersion method.
	PostVersionFunc func() string

	// PreVersionFunc mocks the PreVersion method.
	PreVersionFunc func() string
	// contains filtered or unexported fields
}

MigrationMock is a mock implementation of gh.Migration.

func TestSomethingThatUsesMigration(t *testing.T) {

	// make and configure a mocked gh.Migration
	mockedMigration := &MigrationMock{
		DoFunc: func(config *ghConfig.Config) error {
			panic("mock out the Do method")
		},
		PostVersionFunc: func() string {
			panic("mock out the PostVersion method")
		},
		PreVersionFunc: func() string {
			panic("mock out the PreVersion method")
		},
	}

	// use mockedMigration in code that requires gh.Migration
	// and then make assertions.

}

func (*MigrationMock) Do

func (mock *MigrationMock) Do(config *ghConfig.Config) error

Do calls DoFunc.

func (*MigrationMock) DoCalls

func (mock *MigrationMock) DoCalls() []struct {
	Config *ghConfig.Config
}

DoCalls gets all the calls that were made to Do. Check the length with:

len(mockedMigration.DoCalls())

func (*MigrationMock) PostVersion

func (mock *MigrationMock) PostVersion() string

PostVersion calls PostVersionFunc.

func (*MigrationMock) PostVersionCalls

func (mock *MigrationMock) PostVersionCalls() []struct {
}

PostVersionCalls gets all the calls that were made to PostVersion. Check the length with:

len(mockedMigration.PostVersionCalls())

func (*MigrationMock) PreVersion

func (mock *MigrationMock) PreVersion() string

PreVersion calls PreVersionFunc.

func (*MigrationMock) PreVersionCalls

func (mock *MigrationMock) PreVersionCalls() []struct {
}

PreVersionCalls gets all the calls that were made to PreVersion. Check the length with:

len(mockedMigration.PreVersionCalls())

Jump to

Keyboard shortcuts

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