helper

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddReqRes

func AddReqRes(ngsi *ngsilib.NGSI, r MockHTTPReqRes)

func GetStderrString

func GetStderrString(c *ngsicli.Context) string

func GetStdoutString

func GetStdoutString(c *ngsicli.Context) string

func MockGetReader

func MockGetReader(s string) (ngsilib.FileLib, error)

func MockGetReaderError

func MockGetReaderError(s string) (ngsilib.FileLib, error)

func MockReadAll

func MockReadAll(s string) (bytes []byte, err error)

MockReader

func MockReadAllError

func MockReadAllError(s string) (bytes []byte, err error)

func NewHttpHeader

func NewHttpHeader(key, value string) http.Header

func SetClientHTTP

func SetClientHTTP(c *ngsicli.Context, reqRes ...MockHTTPReqRes)

func SetFilePatAbsError

func SetFilePatAbsError(ngsi *ngsilib.NGSI, p int)

func SetJSONDecodeErr

func SetJSONDecodeErr(ngsi *ngsilib.NGSI, p int)

func SetJSONEncodeErr

func SetJSONEncodeErr(ngsi *ngsilib.NGSI, p int)

func SetJSONIndentError

func SetJSONIndentError(ngsi *ngsilib.NGSI)

func SetReadFileError

func SetReadFileError(ngsi *ngsilib.NGSI, p int)

func SetupTest

func SetupTest(app *ngsicli.App, args []string) *ngsicli.Context

func SetupTestInitCmd

func SetupTestInitCmd(callback func(*ngsilib.NGSI)) *ngsicli.Context

func SetupTestInitNGSI

func SetupTestInitNGSI() *ngsilib.NGSI

func SetupTestWithConfig

func SetupTestWithConfig(app *ngsicli.App, args []string, config string) *ngsicli.Context

func SetupTestWithConfigAndCache

func SetupTestWithConfigAndCache(app *ngsicli.App, args []string, config, cache string) *ngsicli.Context

func StrPtr

func StrPtr(s string) *string

func UrlParse

func UrlParse(s string) *url.URL

Types

type MockFileLib

type MockFileLib struct {
	Name              string
	OpenError         error
	CloseError        error
	ReadallError      error
	ReadallData       []byte
	FilePathAbsString string
	FilePathAbsError  [5]error

	ReadFileData  []byte
	ReadFileError [5]error

	FileError  *bufio.Reader
	FileError2 *bufio.Reader
	IoReader   *bufio.Reader
	// contains filtered or unexported fields
}

func (*MockFileLib) Close

func (f *MockFileLib) Close() error

func (*MockFileLib) File

func (f *MockFileLib) File() bufio.Reader

func (*MockFileLib) FilePathAbs

func (f *MockFileLib) FilePathAbs(path string) (string, error)

func (*MockFileLib) Open

func (f *MockFileLib) Open(path string) (err error)

func (*MockFileLib) ReadAll

func (f *MockFileLib) ReadAll(r io.Reader) ([]byte, error)

func (*MockFileLib) ReadFile

func (f *MockFileLib) ReadFile(filename string) ([]byte, error)

func (*MockFileLib) SetReader

func (f *MockFileLib) SetReader(r io.Reader)

type MockFilePathLib

type MockFilePathLib struct {
	PathAbsErr error
}

func (*MockFilePathLib) FilePathAbs

func (i *MockFilePathLib) FilePathAbs(path string) (string, error)

func (*MockFilePathLib) FilePathBase

func (i *MockFilePathLib) FilePathBase(path string) string

func (*MockFilePathLib) FilePathJoin

func (i *MockFilePathLib) FilePathJoin(elem ...string) string

type MockHTTP

type MockHTTP struct {
	ReqRes []MockHTTPReqRes
	// contains filtered or unexported fields
}

MockHTTPReqRes is ...

func NewMockHTTP

func NewMockHTTP() *MockHTTP

func (*MockHTTP) Request

func (h *MockHTTP) Request(method string, url *url.URL, headers map[string]string, body interface{}) (*http.Response, []byte, error)

Request is ...

type MockHTTPReqRes

type MockHTTPReqRes struct {
	Res        http.Response
	ResBody    []byte
	ResHeader  http.Header
	Err        error
	StatusCode int
	ReqData    []byte
	Path       string
	RawQuery   *string
}

type MockIoLib

type MockIoLib struct {
	OpenErr    error
	EncodeErr  error
	Filename   *string
	HomeDir    error
	PathAbs    error
	StatErr    error
	Tokens     *string
	TruncIndex int
	Trunc      []error
}

func (*MockIoLib) Close

func (io *MockIoLib) Close() error

func (*MockIoLib) Decode

func (io *MockIoLib) Decode(v interface{}) error

func (*MockIoLib) Encode

func (io *MockIoLib) Encode(v interface{}) error

func (*MockIoLib) FileName

func (io *MockIoLib) FileName() *string

func (*MockIoLib) FilePathAbs

func (io *MockIoLib) FilePathAbs(path string) (string, error)

func (*MockIoLib) FilePathJoin

func (io *MockIoLib) FilePathJoin(elem ...string) string

func (*MockIoLib) Getenv

func (io *MockIoLib) Getenv(key string) string

func (*MockIoLib) MkdirAll

func (io *MockIoLib) MkdirAll(path string, perm os.FileMode) error

func (*MockIoLib) Open

func (io *MockIoLib) Open() (err error)

func (*MockIoLib) OpenFile

func (io *MockIoLib) OpenFile(flag int, perm os.FileMode) (err error)

func (*MockIoLib) SetFileName

func (io *MockIoLib) SetFileName(filename *string)

func (*MockIoLib) Stat

func (io *MockIoLib) Stat(filename string) (os.FileInfo, error)

func (*MockIoLib) Truncate

func (io *MockIoLib) Truncate(size int64) error

func (*MockIoLib) UserConfigDir

func (io *MockIoLib) UserConfigDir() (string, error)

func (*MockIoLib) UserHomeDir

func (io *MockIoLib) UserHomeDir() (string, error)

type MockIoutilLib

type MockIoutilLib struct {
	CopyErr      error
	ReadFullErr  error
	ReadFullData []byte
	WriteFileErr error
	ReadFileErr  error
	ReadFileData []byte
	WriteSkip    bool
}

func (*MockIoutilLib) Copy

func (i *MockIoutilLib) Copy(dst io.Writer, src io.Reader) (int64, error)

func (*MockIoutilLib) ReadFile

func (i *MockIoutilLib) ReadFile(filename string) ([]byte, error)

func (*MockIoutilLib) ReadFull

func (i *MockIoutilLib) ReadFull(r io.Reader, buf []byte) (n int, err error)

func (*MockIoutilLib) WriteFile

func (i *MockIoutilLib) WriteFile(filename string, data []byte, perm os.FileMode) error

type MockJSONLib

type MockJSONLib struct {
	IndentErr error
	ValidErr  *bool
	Jsonlib   ngsilib.JSONLib
	DecodeErr [5]error
	EncodeErr [5]error
	// contains filtered or unexported fields
}

func (*MockJSONLib) Decode

func (j *MockJSONLib) Decode(r io.Reader, v interface{}) error

func (*MockJSONLib) Encode

func (j *MockJSONLib) Encode(w io.Writer, v interface{}) error

func (*MockJSONLib) Indent

func (j *MockJSONLib) Indent(dst *bytes.Buffer, src []byte, prefix, indent string) error

func (*MockJSONLib) Valid

func (j *MockJSONLib) Valid(data []byte) bool

type MockMultiPart

type MockMultiPart struct {
	CreatePartErr error
	CloseErr      error
}

func (*MockMultiPart) NewWriter

func (m *MockMultiPart) NewWriter(w io.Writer) ngsilib.MultiPartLib

type MockMultiPartLib

type MockMultiPartLib struct {
	CreatePartErr error
	CloseErr      error
	Mw            *multipart.Writer
}

func (MockMultiPartLib) Close

func (m MockMultiPartLib) Close() error

func (MockMultiPartLib) CreatePart

func (m MockMultiPartLib) CreatePart(header textproto.MIMEHeader) (io.Writer, error)

func (MockMultiPartLib) FormDataContentType

func (m MockMultiPartLib) FormDataContentType() string

type MockNetLib

type MockNetLib struct {
	AddrErr              error
	ListenAndServeErr    error
	ListenAndServeTLSErr error
}

func (*MockNetLib) InterfaceAddrs

func (n *MockNetLib) InterfaceAddrs() ([]net.Addr, error)

func (*MockNetLib) ListenAndServe

func (n *MockNetLib) ListenAndServe(addr string, handler http.Handler) error

func (*MockNetLib) ListenAndServeTLS

func (n *MockNetLib) ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error

type MockSyslogLib

type MockSyslogLib struct {
	Err error
	Buf *bytes.Buffer
}

func (*MockSyslogLib) New

func (s *MockSyslogLib) New() (io.Writer, error)

type MockTimeLib

type MockTimeLib struct {
	DateTime   string
	UnixTime   int64
	TimeFormat *string
	TTime      *time.Time
}

func (*MockTimeLib) Format

func (t *MockTimeLib) Format(layout string) string

func (*MockTimeLib) Now

func (t *MockTimeLib) Now() time.Time

func (*MockTimeLib) NowUnix

func (t *MockTimeLib) NowUnix() int64

func (*MockTimeLib) Unix

func (t *MockTimeLib) Unix(sec int64, nsec int64) time.Time

type MockZipFile

type MockZipFile struct {
}

func (*MockZipFile) DataOffset

func (f *MockZipFile) DataOffset() (offset int64, err error)

func (*MockZipFile) Open

func (f *MockZipFile) Open() (io.ReadCloser, error)

type MockZipLib

type MockZipLib struct {
	Zip       error
	ZipReader *zip.Reader
}

func (*MockZipLib) NewReader

func (z *MockZipLib) NewReader(r io.ReaderAt, size int64) (*zip.Reader, error)

Jump to

Keyboard shortcuts

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