Documentation ¶
Overview ¶
Package mockdatasource provides mock objects for datasource package
Index ¶
- func NopWriteCloser(w io.Writer) io.WriteCloser
- type MockDatasource
- func (ds *MockDatasource) CloseDatabase(log *logrus.Entry, admin bool, nodb bool) error
- func (ds *MockDatasource) CloseFile(log *logrus.Entry) error
- func (ds *MockDatasource) FillTmplValues() datasource.TmplValues
- func (ds *MockDatasource) GetEngine() datasource.Engine
- func (ds *MockDatasource) GetHash(log *logrus.Entry, admin bool, nodb bool) string
- func (ds *MockDatasource) GetName() string
- func (ds *MockDatasource) GetNamedTag(name string) string
- func (ds *MockDatasource) GetType() datasource.Type
- func (ds *MockDatasource) IsTableEmpty(ctx context.Context, log *logrus.Entry, table string) (bool, error)
- func (ds *MockDatasource) IsTableExists(ctx context.Context, log *logrus.Entry, table string) (bool, error)
- func (ds *MockDatasource) IsTransaction() bool
- func (ds *MockDatasource) OpenDatabase(log *logrus.Entry, admin bool, nodb bool) (*sql.DB, error)
- func (ds *MockDatasource) OpenReadFile(log *logrus.Entry) (io.ReadCloser, error)
- func (ds *MockDatasource) OpenWriteFile(log *logrus.Entry) (io.WriteCloser, error)
- func (ds *MockDatasource) ResetFile(log *logrus.Entry) error
- func (ds *MockDatasource) Stat() (os.FileInfo, error)
- type MockDatasources
- func (dss *MockDatasources) CloseAll(log *logrus.Entry)
- func (dss *MockDatasources) Insert(limited bool, tags []string, dsTypes []datasource.Type, ...)
- func (dss *MockDatasources) LoadAll(path string, log *logrus.Entry) error
- func (dss *MockDatasources) Lookup(log *logrus.Entry, tags []string, limitedTags []string, ...) ([]datasource.Datasourcer, []datasource.Datasourcer, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NopWriteCloser ¶
func NopWriteCloser(w io.Writer) io.WriteCloser
NopWriteCloser returns a nopWriteCloser.
Types ¶
type MockDatasource ¶
type MockDatasource struct { Name string Type datasource.Type Database string Engine datasource.Engine Inline string Host string Port string User string UserPw string Admin string AdminPw string URL string URLAdmin string URLNoDb string Transaction bool Schema string FilePath string TmpFilePath string Gzip bool Zip bool FileHandle io.Closer Filewriter bool Tags []string ErrorOpenDb error ErrorOpenFile error ErrorReset error ErrorClose error FileNotExists bool TableExists bool TableEmpty bool MockedDb *sql.DB WriteBuf bytes.Buffer }
MockDatasource is fake datasource object for test purpose.
func (*MockDatasource) CloseDatabase ¶ added in v1.3.0
CloseDatabase close connection to the corresponding database only if no more used.
func (*MockDatasource) CloseFile ¶
func (ds *MockDatasource) CloseFile(log *logrus.Entry) error
CloseFile close the file and rename the temporary file to real name (if exists).
func (*MockDatasource) FillTmplValues ¶
func (ds *MockDatasource) FillTmplValues() datasource.TmplValues
FillTmplValues return a struct for template operation with value corresponding to the provided datasource.
func (*MockDatasource) GetEngine ¶
func (ds *MockDatasource) GetEngine() datasource.Engine
GetEngine return the engine enum value.
func (*MockDatasource) GetHash ¶ added in v1.1.0
GetHash returns uniq hash for the datasource final destination (more than one datasource could have the same hash by example same database engine).
func (*MockDatasource) GetName ¶
func (ds *MockDatasource) GetName() string
GetName return the name of the datasource.
func (*MockDatasource) GetNamedTag ¶
func (ds *MockDatasource) GetNamedTag(name string) string
GetNamedTag return the value of the tag with the provided name or "" if not exists.
func (*MockDatasource) GetType ¶
func (ds *MockDatasource) GetType() datasource.Type
GetType return the type enum value.
func (*MockDatasource) IsTableEmpty ¶ added in v1.2.2
func (ds *MockDatasource) IsTableEmpty(ctx context.Context, log *logrus.Entry, table string) (bool, error)
IsTableEmpty return true if the table empty.
func (*MockDatasource) IsTableExists ¶ added in v1.2.2
func (ds *MockDatasource) IsTableExists(ctx context.Context, log *logrus.Entry, table string) (bool, error)
IsTableExists return true if the table exists.
func (*MockDatasource) IsTransaction ¶
func (ds *MockDatasource) IsTransaction() bool
IsTransaction return true if the datasource has transaction.
func (*MockDatasource) OpenDatabase ¶
OpenDatabase open connection to the corresponding database.
func (*MockDatasource) OpenReadFile ¶
func (ds *MockDatasource) OpenReadFile(log *logrus.Entry) (io.ReadCloser, error)
OpenReadFile open and return a io.ReadCloser on the WriteBuf element.
func (*MockDatasource) OpenWriteFile ¶
func (ds *MockDatasource) OpenWriteFile(log *logrus.Entry) (io.WriteCloser, error)
OpenWriteFile open and return a io.WriteCloser on the WriteBuf element.
type MockDatasources ¶
type MockDatasources struct {
// contains filtered or unexported fields
}
MockDatasources is fake datasources object for test purpose.
func New ¶
func New() *MockDatasources
New returns a new Datasources object with elments initialized.
func (*MockDatasources) CloseAll ¶
func (dss *MockDatasources) CloseAll(log *logrus.Entry)
CloseAll do nothing, return an error if path is empty.
func (*MockDatasources) Insert ¶
func (dss *MockDatasources) Insert(limited bool, tags []string, dsTypes []datasource.Type, engines []datasource.Engine, ds []*MockDatasource)
Insert add a Mocked datasource to the array.
func (*MockDatasources) LoadAll ¶
func (dss *MockDatasources) LoadAll(path string, log *logrus.Entry) error
LoadAll do nothing, return an error if path is empty.
func (*MockDatasources) Lookup ¶
func (dss *MockDatasources) Lookup(log *logrus.Entry, tags []string, limitedTags []string, dsTypes []datasource.Type, engines []datasource.Engine) ([]datasource.Datasourcer, []datasource.Datasourcer, error)
Lookup : return the corresponding array of Mocked datasources WARNING: the algorithm of lookup is much simpler than the one from the object, all the parameters must be exactly the same !