Help us shape the future of Go! Take the 2026 Go Developer Survey

mocks

package
v1.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateEmptyHttpResponse

func CreateEmptyHttpResponse(request *http.Request, statusCode int) (*http.Response, error)

Creates a mocked HTTP response with the specified status code and no body

func CreateHttpResponseWithBody

func CreateHttpResponseWithBody[T any](request *http.Request, statusCode int, body T) (*http.Response, error)

Creates a mocked HTTP response with the specified status code and body

func CreateJwtToken added in v1.23.15

func CreateJwtToken(t testing.TB, claims any) string

CreateJwtToken creates a JWT-like token for tests without using hardcoded token literals.

func NewMockUserAgentPolicy

func NewMockUserAgentPolicy(userAgent string) *mockUserAgentPolicy

func ReadHttpBody

func ReadHttpBody(body io.ReadCloser, v any) error

ReadHttpBody reads the body of an HTTP request or response and converts it into the specified object

Types

type MockContext

type MockContext struct {
	Credentials                    *MockCredentials
	Context                        *context.Context
	Console                        *mockinput.MockConsole
	HttpClient                     *mockhttp.MockHttpClient
	CoreClientOptions              *azcore.ClientOptions
	ArmClientOptions               *arm.ClientOptions
	CommandRunner                  *mockexec.MockCommandRunner
	ConfigManager                  *mockconfig.MockConfigManager
	Container                      *ioc.NestedContainer
	AlphaFeaturesManager           *alpha.FeatureManager
	SubscriptionCredentialProvider *MockSubscriptionCredentialProvider
	MultiTenantCredentialProvider  *MockMultiTenantCredentialProvider
	Config                         config.Config
	Clock                          *clock.Mock
}

func NewMockContext

func NewMockContext(ctx context.Context) *MockContext

type MockCredentials

type MockCredentials struct {
	GetTokenFn func(ctx context.Context, options policy.TokenRequestOptions) (azcore.AccessToken, error)
}

func (*MockCredentials) GetToken

type MockMultiTenantCredentialProvider

type MockMultiTenantCredentialProvider struct {
	TokenMap map[string]MockCredentials
}

func (*MockMultiTenantCredentialProvider) GetTokenCredential

func (c *MockMultiTenantCredentialProvider) GetTokenCredential(
	ctx context.Context, tenantId string) (azcore.TokenCredential, error)

type MockSubscriptionCredentialProvider

type MockSubscriptionCredentialProvider struct {
}

func (*MockSubscriptionCredentialProvider) CredentialForSubscription

func (scp *MockSubscriptionCredentialProvider) CredentialForSubscription(
	ctx context.Context,
	subscriptionId string,
) (azcore.TokenCredential, error)

Jump to

Keyboard shortcuts

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