apiwrappers

package
v0.0.0-...-0549321 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFakeFileFromOSPipe

func CreateFakeFileFromOSPipe(t *testing.T, errOnRead bool, errOnWrite bool) (r *FakeFile, w *FakeFile, err error)

CreateFakeFileFromOSPipe creates a new FakeFile instance from a call to os.Pipe() the failOnRead and failOnWrite parameters determine if the file should error on read or write r will only error on read, w will only error on write (even if you set both to fail)

If you need to test both see CreateFakeFileFromOSPipeExtended

func CreateFakeFileFromOSPipeExtended

func CreateFakeFileFromOSPipeExtended(t *testing.T, rErrOnRead bool, rErrOnWrite bool, wErrOnRead bool, wErrOnWrite bool) (r *FakeFile, w *FakeFile, err error)

CreateFakeFileFromOSPipeExtended creates a new FakeFile instance from a call to os.Pipe() the failOnRead and failOnWrite parameters determine if the file should error on read or write

func NewFakeCommand

func NewFakeCommand(name string, shouldFailToRun bool, args ...string) *bbUtilApiWrappers.Command

NewFakeCommand - create a new fake command

Types

type FakeCommandRunner

type FakeCommandRunner struct {
	// contains filtered or unexported fields
}

FakeCommandRunner - a fake command runner

func (*FakeCommandRunner) Run

func (c *FakeCommandRunner) Run() error

func (*FakeCommandRunner) SetStderr

func (c *FakeCommandRunner) SetStderr(writer io.Writer)

SetStderr - set the stderr for the command and the underlying runner, if applicable

func (*FakeCommandRunner) SetStdin

func (c *FakeCommandRunner) SetStdin(reader io.Reader)

SetStdin - set the stdin for the command and the underlying runner, if applicable

func (*FakeCommandRunner) SetStdout

func (c *FakeCommandRunner) SetStdout(writer io.Writer)

SetStdout - set the stdout for the command and the underlying runner, if applicable

type FakeFile

type FakeFile struct {
	File commonInterfaces.FileLike

	SetFail struct {
		Chdir            bool
		Chmod            bool
		Chown            bool
		Close            bool
		Fd               bool
		Name             bool
		Read             bool
		ReadAt           bool
		ReadDir          bool
		ReadFrom         bool
		Readdir          bool
		Readdirnames     bool
		Seek             bool
		SetDeadline      bool
		SetReadDeadline  bool
		SetWriteDeadline bool
		Stat             bool
		Sync             bool
		SyscallConn      bool
		Truncate         bool
		Write            bool
		WriteAt          bool
		WriteString      bool
		WriteTo          bool
	}
	// contains filtered or unexported fields
}

FakeFile is a fake implementation of os.File that can be used for testing purposes

func CreateFakeFileFromFileLike

func CreateFakeFileFromFileLike(t *testing.T, shouldErrorOnRead bool, shouldErrorOnWrite bool, actualFile commonInterfaces.FileLike) (*FakeFile, error)

CreateFakeFileFromFileLike creates a new FakeFile instance from an existing FileLike (e.g. os.File)

func (*FakeFile) Chdir

func (f *FakeFile) Chdir() error

Write writes the given byte slice to the file

func (*FakeFile) Chmod

func (f *FakeFile) Chmod(mode fs.FileMode) error

Chmod changes the mode of the file

func (*FakeFile) Chown

func (f *FakeFile) Chown(uid int, gid int) error

Chown changes the owner and group of the file

func (*FakeFile) Close

func (f *FakeFile) Close() error

Close closes the file

func (*FakeFile) Fd

func (f *FakeFile) Fd() uintptr

Fd returns the file descriptor

func (*FakeFile) Name

func (f *FakeFile) Name() string

Name returns the file name

func (*FakeFile) Read

func (f *FakeFile) Read(b []byte) (n int, err error)

Read reads the given byte slice from the file

func (*FakeFile) ReadAt

func (f *FakeFile) ReadAt(b []byte, off int64) (n int, err error)

ReadAt reads the given byte slice from the file at the given offset

func (*FakeFile) ReadDir

func (f *FakeFile) ReadDir(n int) ([]fs.DirEntry, error)

ReadDir reads the directory

func (*FakeFile) ReadFrom

func (f *FakeFile) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads from the given reader

func (*FakeFile) Readdir

func (f *FakeFile) Readdir(n int) ([]fs.FileInfo, error)

Readdir reads the directory

func (*FakeFile) Readdirnames

func (f *FakeFile) Readdirnames(n int) (names []string, err error)

Readdirnames reads the directory names

func (*FakeFile) Seek

func (f *FakeFile) Seek(offset int64, whence int) (ret int64, err error)

Seek seeks to the given offset

func (*FakeFile) SetDeadline

func (f *FakeFile) SetDeadline(t time.Time) error

SetDeadline sets the deadline

func (*FakeFile) SetReadDeadline

func (f *FakeFile) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline

func (*FakeFile) SetWriteDeadline

func (f *FakeFile) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline

func (*FakeFile) Stat

func (f *FakeFile) Stat() (fs.FileInfo, error)

Stat returns the file info

func (*FakeFile) Sync

func (f *FakeFile) Sync() error

Sync syncs the file

func (*FakeFile) SyscallConn

func (f *FakeFile) SyscallConn() (syscall.RawConn, error)

SyscallConn returns the raw connection

func (*FakeFile) Truncate

func (f *FakeFile) Truncate(size int64) error

Truncate truncates the file

func (*FakeFile) Write

func (f *FakeFile) Write(b []byte) (n int, err error)

Write writes the given byte slice to the file

func (*FakeFile) WriteAt

func (f *FakeFile) WriteAt(b []byte, off int64) (n int, err error)

WriteAt writes the given byte slice to the file at the given offset

func (*FakeFile) WriteString

func (f *FakeFile) WriteString(s string) (n int, err error)

WriteString writes the given string to the file

func (*FakeFile) WriteTo

func (f *FakeFile) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes the file to the given writer

type FakeFileError

type FakeFileError struct {
	// contains filtered or unexported fields
}

FakeFileError is an error that is returned when the FakeFile is intentionally errored

func (*FakeFileError) Error

func (f *FakeFileError) Error() string

Error returns the error message string

type FakeIstioClientSet

type FakeIstioClientSet struct {
	VirtualServicesList *apisV1Beta1.VirtualServiceList
	// contains filtered or unexported fields
}

FakeIstioClientSet

func NewFakeIstioClientSet

func NewFakeIstioClientSet(vsList *apisV1Beta1.VirtualServiceList, sf SetFail) *FakeIstioClientSet

NewFakeIstioClientSet intializes and returns a new FakeIstioClientSet

func (*FakeIstioClientSet) NetworkingV1beta1

NetworkingV1beta1 intializes and returns a new FakeNetworkingV1beta1 object containing the configured list of virtual services

type FakeNetworkingV1beta1

type FakeNetworkingV1beta1 struct {
	DestinationRulesGetter typedV1Beta1.DestinationRulesGetter
	GatewaysGetter         typedV1Beta1.GatewaysGetter
	ProxyConfigsGetter     typedV1Beta1.ProxyConfigsGetter
	ServiceEntriesGetter   typedV1Beta1.ServiceEntriesGetter
	SidecarsGetter         typedV1Beta1.SidecarsGetter
	VirtualServicesGetter  typedV1Beta1.VirtualServicesGetter
	WorkloadEntriesGetter  typedV1Beta1.WorkloadEntriesGetter
	WorkloadGroupsGetter   typedV1Beta1.WorkloadGroupsGetter

	VirtualServicesList *apisV1Beta1.VirtualServiceList
	// contains filtered or unexported fields
}

FakeNetworkingV1beta1

func (*FakeNetworkingV1beta1) DestinationRules

func (f *FakeNetworkingV1beta1) DestinationRules(namespace string) typedV1Beta1.DestinationRuleInterface

DestinationRules returns nil

func (*FakeNetworkingV1beta1) Gateways

Gateways returns nil

func (*FakeNetworkingV1beta1) ProxyConfigs

ProxyConfigs returns nil

func (*FakeNetworkingV1beta1) RESTClient

func (f *FakeNetworkingV1beta1) RESTClient() rest.Interface

RESTClient returns nil

func (*FakeNetworkingV1beta1) ServiceEntries

func (f *FakeNetworkingV1beta1) ServiceEntries(namespace string) typedV1Beta1.ServiceEntryInterface

ServiceEntries returns nil

func (*FakeNetworkingV1beta1) Sidecars

Sidecars returns nil

func (*FakeNetworkingV1beta1) VirtualServices

func (f *FakeNetworkingV1beta1) VirtualServices(namespace string) typedV1Beta1.VirtualServiceInterface

VirtualServices returns nil

func (*FakeNetworkingV1beta1) WorkloadEntries

func (f *FakeNetworkingV1beta1) WorkloadEntries(namespace string) typedV1Beta1.WorkloadEntryInterface

WorkloadEntries returns nil

func (*FakeNetworkingV1beta1) WorkloadGroups

func (f *FakeNetworkingV1beta1) WorkloadGroups(namespace string) typedV1Beta1.WorkloadGroupInterface

WorkloadGroups returns nil

type FakeReaderWriter

type FakeReaderWriter struct {
	ActualBuffer ReaderWriter
	// contains filtered or unexported fields
}

FakeReaderWriter is a fake implementation of io.Writer that can be used for testing purposes

func CreateFakeReaderWriter

func CreateFakeReaderWriter(t *testing.T, shouldErrorOnRead bool, shouldErrorOnWrite bool) *FakeReaderWriter

CreateFakeReaderWriter creates a new FakeReaderWriter instance with a backing &bytes.Buffer

func CreateFakeWriterFromReaderWriter

func CreateFakeWriterFromReaderWriter(t *testing.T, shouldErrorOnRead bool, shouldErrorOnWrite bool, actualBuffer ReaderWriter) *FakeReaderWriter

CreateFakeWriterFromReaderWriter creates a new FakeReaderWriter instance from an existing ReaderWriter

func (*FakeReaderWriter) Read

func (f *FakeReaderWriter) Read(p []byte) (n int, err error)

Read reads the given byte slice from the buffer

func (*FakeReaderWriter) Write

func (f *FakeReaderWriter) Write(p []byte) (n int, err error)

Write writes the given byte slice to the buffer

type FakeVirtualService

type FakeVirtualService struct {
	typedV1Beta1.VirtualServiceExpansion
	VirtualServicesList *apisV1Beta1.VirtualServiceList
	// contains filtered or unexported fields
}

FakeVirtualService

func (*FakeVirtualService) Apply

Apply returns nil, nil

func (*FakeVirtualService) ApplyStatus

ApplyStatus returns nil, nil

func (*FakeVirtualService) Create

Create returns nil, nil

func (*FakeVirtualService) Delete

func (f *FakeVirtualService) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error

Delete returns nil

func (*FakeVirtualService) DeleteCollection

func (f *FakeVirtualService) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error

DeleteCollection returns nil

func (*FakeVirtualService) Get

Get returns nil, nil

func (*FakeVirtualService) List

List returns a list of virtual service resources

func (*FakeVirtualService) Patch

func (f *FakeVirtualService) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, args ...string) (*apisV1Beta1.VirtualService, error)

Patch returns nil, nil

func (*FakeVirtualService) Update

Update returns nil, nil

func (*FakeVirtualService) UpdateStatus

UpdateStatus returns nil, nil

func (*FakeVirtualService) Watch

Watch returns nil, nil

type FakeWriterError

type FakeWriterError struct {
	// contains filtered or unexported fields
}

FakeWriterError is an error that is returned when the FakeWriter is intentionally errored

func (*FakeWriterError) Error

func (f *FakeWriterError) Error() string

Error returns the error message string

type ReaderWriter

type ReaderWriter interface {
	io.Reader
	io.Writer
}

ReaderWriter is an interface that combines the io.Reader and io.Writer interfaces

type SetFail

type SetFail struct {
	GetList bool
}

Flags to control the fake client behavior and force functions to fail

Jump to

Keyboard shortcuts

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