test

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

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 ReadFile

func ReadFile(fileName string) string

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

Types

type MockClient

type MockClient struct {
	GetAccountsFunc            func(ctx context.Context) ([]*client.Account, error)
	GetRolesFunc               func(ctx context.Context) ([]*client.Role, annotations.Annotations, error)
	GetGroupsFunc              func(ctx context.Context) ([]*client.Group, error)
	GetDefaultRoleFunc         func(ctx context.Context) (string, error)
	CreateAccountFunc          func(ctx context.Context, username string, password string) (*client.Account, annotations.Annotations, error)
	UpdateUserRoleFunc         func(ctx context.Context, userID string, roleID string) (annotations.Annotations, error)
	RemoveUserRoleFunc         func(ctx context.Context, userID string, roleID string) (annotations.Annotations, error)
	GetSubjectsForAllRolesFunc func(ctx context.Context) (map[string][]string, error)
	GetUserRolesFunc           func(ctx context.Context, userID string) ([]string, error)
	GetRoleSubjectsFunc        func(ctx context.Context, roleID string) ([]string, error)
	GetRoleUsersFunc           func(ctx context.Context, roleID string) ([]*client.Account, error)
	GetRBACConfigMapFunc       func(ctx context.Context) (*corev1.ConfigMap, error)
}

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

func (*MockClient) CreateAccount

func (m *MockClient) CreateAccount(ctx context.Context, username string, password string) (*client.Account, annotations.Annotations, error)

CreateAccount calls the mock method if it is defined.

func (*MockClient) GetAccounts

func (m *MockClient) GetAccounts(ctx context.Context) ([]*client.Account, error)

GetAccounts calls the mock method if it is defined.

func (*MockClient) GetDefaultRole

func (m *MockClient) GetDefaultRole(ctx context.Context) (string, error)

GetDefaultRole calls the mock method if it is defined.

func (*MockClient) GetGroups

func (m *MockClient) GetGroups(ctx context.Context) ([]*client.Group, error)

func (*MockClient) GetRBACConfigMap added in v0.1.0

func (m *MockClient) GetRBACConfigMap(ctx context.Context) (*corev1.ConfigMap, error)

GetRBACConfigMap calls the mock method if it is defined.

func (*MockClient) GetRoleSubjects

func (m *MockClient) GetRoleSubjects(ctx context.Context, roleID string) ([]string, error)

GetRoleSubjects calls the mock method if it is defined.

func (*MockClient) GetRoleUsers

func (m *MockClient) GetRoleUsers(ctx context.Context, roleID string) ([]*client.Account, error)

GetRoleUsers calls the mock method if it is defined.

func (*MockClient) GetRoles

GetRoles calls the mock method if it is defined.

func (*MockClient) GetSubjectsForAllRoles

func (m *MockClient) GetSubjectsForAllRoles(ctx context.Context) (map[string][]string, error)

GetSubjectsForAllRoles calls the mock method if it is defined.

func (*MockClient) GetUserRoles

func (m *MockClient) GetUserRoles(ctx context.Context, userID string) ([]string, error)

GetUserRoles calls the mock method if it is defined.

func (*MockClient) RemoveUserRole

func (m *MockClient) RemoveUserRole(ctx context.Context, userID string, roleID string) (annotations.Annotations, error)

RemoveUserRole calls the mock method if it is defined.

func (*MockClient) UpdateUserRole

func (m *MockClient) UpdateUserRole(ctx context.Context, userID string, roleID string) (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