apptest

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertCmdsPartiallyMatch

func AssertCmdsPartiallyMatch(t *testing.T, expectedCmds []string, actualExecutedCmds []*exec.Cmd)

func AssertEnvValuesMatch

func AssertEnvValuesMatch(t *testing.T, expectedEnvs conv.KeyValues, actualCmdEnvs []string)

func AssertErrorExpectation

func AssertErrorExpectation(t *testing.T, err error, exp *ErrorExpectation)

func AssertFileMatchesExpectation

func AssertFileMatchesExpectation(fe *FileExpectation) (isExpectationMatched bool, nonMatchedReason string, err error)

func AssertFileMatchesExpectationOS

func AssertFileMatchesExpectationOS(filePath string, fe *FileExpectation) (isMatched bool, reason string, err error)

func DeleteFileIfExists

func DeleteFileIfExists(filePath string) error

func DeleteFiles

func DeleteFiles(files []string) error

func StartFTPServer

func StartFTPServer(ctx context.Context, port int, waitForStarting time.Duration) (*url.URL, error)

func StartHTTPServer

func StartHTTPServer(isHTTPS bool) (u *url.URL, srv *httptest.Server, err error)

Types

type ChownInput

type ChownInput struct {
	TargetFilePath string
	UserName       string
	GroupName      string
}

type ErrorExpectation

type ErrorExpectation struct {
	PartialText string
	FullText    string
	FullError   error
}

type FakeFile

type FakeFile struct {
	Nam      string
	Contents string
	FileMode os.FileMode
}

FakeFile implements FileLike and also os.FileInfo.

func (*FakeFile) IsDir

func (f *FakeFile) IsDir() bool

func (*FakeFile) ModTime

func (f *FakeFile) ModTime() time.Time

func (*FakeFile) Mode

func (f *FakeFile) Mode() os.FileMode

func (*FakeFile) Name

func (f *FakeFile) Name() string

func (*FakeFile) Size

func (f *FakeFile) Size() int64

func (*FakeFile) Stat

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

func (*FakeFile) Sys

func (f *FakeFile) Sys() interface{}

type FileExpectation

type FileExpectation struct {
	ShouldExist      bool
	ExpectedMode     os.FileMode
	FilePath         string
	ExpectedContent  string
	ExpectedUser     string
	ExpectedGroup    string
	ExpectedEncoding string
}

type FsManagerMock

type FsManagerMock struct {
	FileExistsInputPath      []string
	FileExistsErrToReturn    error
	FileExistsExistsToReturn bool
	ChownInputs              []ChownInput
	ChownErrorToReturn       error
	StatInputName            []string
	StatOutputFileInfo       os.FileInfo
	StatOutputError          error
}

func (*FsManagerMock) Chmod

func (fmm *FsManagerMock) Chmod(targetFilePath string, mode os.FileMode) error

func (*FsManagerMock) Chown

func (fmm *FsManagerMock) Chown(targetFilePath, userName, groupName string) error

func (*FsManagerMock) CopyLocalFile

func (fmm *FsManagerMock) CopyLocalFile(sourceFilePath, targetFilePath string, mode os.FileMode) error

func (*FsManagerMock) CreateDirPathIfNeeded

func (fmm *FsManagerMock) CreateDirPathIfNeeded(targetFilePath string, mode os.FileMode) error

func (*FsManagerMock) DownloadFile

func (fmm *FsManagerMock) DownloadFile(ctx context.Context, targetLocation string, sourceURL *url.URL, skipTLSCheck bool) error

func (*FsManagerMock) FileExists

func (fmm *FsManagerMock) FileExists(filePath string) (bool, error)

func (*FsManagerMock) MoveFile

func (fmm *FsManagerMock) MoveFile(sourceFilePath, targetFilePath string) error

func (*FsManagerMock) ReadEncodedFile

func (fmm *FsManagerMock) ReadEncodedFile(encodingName, fileName string) (contentsUtf8 string, err error)

func (*FsManagerMock) ReadFile

func (fmm *FsManagerMock) ReadFile(filePath string) (content string, err error)

func (*FsManagerMock) Remove

func (fmm *FsManagerMock) Remove(filePath string) error

func (*FsManagerMock) Stat

func (fmm *FsManagerMock) Stat(name string) (os.FileInfo, error)

func (*FsManagerMock) WriteFile

func (fmm *FsManagerMock) WriteFile(name, contents string, mode os.FileMode) error

Jump to

Keyboard shortcuts

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