test

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MockBaseURL     = "https://mock.api.zuper.co"
	MockAccessToken = "mock-access-token"
)

Mock constants.

Variables

This section is empty.

Functions

func CreateMockResponseBody

func CreateMockResponseBody(fileName string) io.ReadCloser

CreateMockResponseBody creates an io.ReadCloser with the contents of the file.

func LoadMockJSON

func LoadMockJSON(fileName string) []byte

LoadMockJSON loads the content of a mock JSON file from /test/mock/ as []byte.

func LoadMockStruct

func LoadMockStruct(fileName string, v interface{})

LoadMockStruct loads a mock JSON file and unmarshals it into the provided interface.

func LoadMockTeamsStruct

func LoadMockTeamsStruct(fileName string, v interface{})

LoadMockTeamsStruct loads a mock JSON file and unmarshals it into the provided interface for teams.

func ReadFile

func ReadFile(fileName string) string

ReadFile loads content from a JSON file from /test/mock/.

func ReadTeamsFile

func ReadTeamsFile(fileName string) string

ReadTeamsFile loads content from a JSON file from /test/mock/ for teams.

Types

type MockClient

type MockClient struct {
	GetUsersFunc             func(ctx context.Context, options client.PageOptions) ([]*client.ZuperUser, string, annotations.Annotations, error)
	GetUserByIDFunc          func(ctx context.Context, userUID string) (*client.ZuperUser, annotations.Annotations, error)
	CreateUserFunc           func(ctx context.Context, user client.UserPayload) (*client.CreateUserResponse, annotations.Annotations, error)
	GetTeamsFunc             func(ctx context.Context, options client.PageOptions) ([]*client.Team, string, annotations.Annotations, error)
	GetTeamUsersFunc         func(ctx context.Context, teamID string) ([]*client.ZuperUser, string, annotations.Annotations, error)
	AssignUserToTeamFunc     func(ctx context.Context, teamUID, userUID string) (*client.AssignUserToTeamResponse, annotations.Annotations, error)
	UnassignUserFromTeamFunc func(ctx context.Context, teamUID, userUID string) (*client.AssignUserToTeamResponse, annotations.Annotations, error)
	UpdateUserRoleFunc       func(ctx context.Context, userUID string, roleID int) (*client.UpdateUserRoleResponse, annotations.Annotations, error)
	UpdateUserAccessRoleFunc func(ctx context.Context, userUID string, accessRoleUID string) (*client.UpdateUserRoleResponse, annotations.Annotations, error)
}

MockClient is a mock implementation of the Zuper client for testing.

func (*MockClient) AssignUserToTeam

func (m *MockClient) AssignUserToTeam(ctx context.Context, teamUID, userUID string) (*client.AssignUserToTeamResponse, annotations.Annotations, error)

AssignUserToTeam calls the mock method if it is defined.

func (*MockClient) CreateUser

CreateUser calls the mock method if it is defined.

func (*MockClient) GetTeamUsers

func (m *MockClient) GetTeamUsers(ctx context.Context, teamID string) ([]*client.ZuperUser, string, annotations.Annotations, error)

GetTeamUsers calls the mock method if it is defined.

func (*MockClient) GetTeams

GetTeams calls the mock method if it is defined.

func (*MockClient) GetUserByID

func (m *MockClient) GetUserByID(ctx context.Context, userUID string) (*client.ZuperUser, annotations.Annotations, error)

GetUserByID calls the mock method if it is defined.

func (*MockClient) GetUsers

GetUsers calls the mock method if it is defined.

func (*MockClient) UnassignUserFromTeam

func (m *MockClient) UnassignUserFromTeam(ctx context.Context, teamUID, userUID string) (*client.AssignUserToTeamResponse, annotations.Annotations, error)

UnassignUserFromTeam calls the mock method if it is defined.

func (*MockClient) UpdateUserAccessRole

func (m *MockClient) UpdateUserAccessRole(ctx context.Context, userUID string, accessRoleUID string) (*client.UpdateUserRoleResponse, annotations.Annotations, error)

func (*MockClient) UpdateUserRole

func (m *MockClient) UpdateUserRole(ctx context.Context, userUID string, roleID int) (*client.UpdateUserRoleResponse, annotations.Annotations, error)

UpdateUserRole calls the mock method if it is defined.

Jump to

Keyboard shortcuts

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