test

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MockAccountID    = "account123"
	MockBaseURL      = "https://mock.api.docusign.net"
	MockAccessToken  = "test-token"
	MockRefreshToken = "test-refresh-token"
	MockUserID       = "u1"
	MockGroupID      = "g1"
)

Variables

This section is empty.

Functions

func CreateMockResponse

func CreateMockResponse(fileName string) *http.Response

CreateMockResponse creates a mock HTTP response with a status and mock response body.

func CreateMockResponseBody

func CreateMockResponseBody(fileName string) io.ReadCloser

CreateMockResponseBody creates a mock response body by reading a file.

func NewTestClient

func NewTestClient(response *http.Response, err error) *client.Client

NewTestClient prepares a Client pointing to a mock endpoint.

func ReadFile

func ReadFile(fileName string) string

ReadFile reads the content of a file from the "mock_responses" folder.

Types

type ExtendedMockClient

type ExtendedMockClient struct {
	*MockClient
	GetAllUsersWithDetailsFunc func(ctx context.Context) ([]*client.UserDetail, annotations.Annotations, error)
}

ExtendedMockClient is an extended version of MockClient with additional functionality for user details.

func (*ExtendedMockClient) GetAllUsersWithDetails

func (m *ExtendedMockClient) GetAllUsersWithDetails(ctx context.Context) ([]*client.UserDetail, annotations.Annotations, error)

GetAllUsersWithDetails returns user details for all users, based on the mocked function.

type MockClient

type MockClient struct {
	GetUsersFunc      func(ctx context.Context, opts client.PageOptions) ([]client.User, string, annotations.Annotations, error)
	GetGroupsFunc     func(ctx context.Context, opts client.PageOptions) ([]client.Group, string, annotations.Annotations, error)
	GetGroupUsersFunc func(ctx context.Context, groupID string, opts client.PageOptions) ([]client.User, string, annotations.Annotations, error)
	CreateUsersFunc   func(ctx context.Context, request client.CreateUsersRequest) (*client.UserCreationResponse, annotations.Annotations, error)
}

MockClient is a mock client used for unit tests that simulates the real client behavior.

func (*MockClient) CreateUsers

CreateUsers creates users based on the mocked function.

func (*MockClient) GetGroupUsers

func (m *MockClient) GetGroupUsers(ctx context.Context, groupID string, opts client.PageOptions) ([]client.User, string, annotations.Annotations, error)

GetGroupUsers returns a list of users for a given group based on the mocked function.

func (*MockClient) GetGroups

GetGroups returns a list of groups based on the mocked function.

func (*MockClient) GetUsers

GetUsers returns a list of users based on the mocked function.

type MockRoundTripper

type MockRoundTripper struct {
	Response *http.Response
	Err      error
	// contains filtered or unexported fields
}

MockRoundTripper is a mock implementation of http.RoundTripper for testing.

func (*MockRoundTripper) RoundTrip

func (m *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip executes the mock RoundTripper function or returns the stored response and error.

Jump to

Keyboard shortcuts

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