Documentation ¶
Overview ¶
Mock is a set of simulated database and bucket functions for unit testing.
Index ¶
- Constants
- Variables
- func Bucket(i int) (string, error)
- func CSV() string
- func Create() (string, error)
- func Database() (db *bolt.DB, path string, err error)
- func Delete(path string) error
- func Export(i int) (string, error)
- func Extension(ext string) (string, error)
- func Item(i int) (string, error)
- func ItemSum(item int) (string, error)
- func MirrorTmp(src string) (string, error)
- func NamedDB() (string, error)
- func Open(path string) (*bolt.DB, string, error)
- func Read(name string) (sum [32]byte, err error)
- func RemoveTmp(path string) (int, error)
- func RootDir() string
- func SensenTmp(path string) (int64, error)
- func Sum(item int, b [32]byte) (bool, error)
- func TempDir() (string, error)
Constants ¶
const ( PrivateFile fs.FileMode = 0o600 // PrivateFile mode means only the owner has read/write access. PrivateDir fs.FileMode = 0o700 // PrivateDir mode means only the owner has read/write/dir access. SevenZip = "test/randomfiles.7z" // NoSuchFile = "qwertryuiop" // NoSuchFile is a non-existent filename. )
Variables ¶
var ( ErrBucket = errors.New("mock bucket number does not exist") ErrExport = errors.New("mock export number does not exist") ErrExtension = errors.New("mock file for extension does not exist") ErrItem = errors.New("mock item number does not exist") ErrLockedDB = errors.New("mock database is locked by the Windows filesystem") ErrNoRoot = errors.New("could not determine the root directory") )
Functions ¶
func CSV ¶ added in v1.1.0
func CSV() string
CSV returns the path to a mock exported comma-separated values file.
func Create ¶ added in v1.1.0
Create the mock database and return its location. Note: If this test fails under Windows, try running `go test ./...` after closing VS Code. https://github.com/electron-userland/electron-builder/issues/3666
func Extension ¶ added in v1.1.0
Extension returns the absolute path of a test file based on an extension.
func ItemSum ¶ added in v1.1.0
ItemSum returns the SHA-256 binary checksum of the test source file item.
func MirrorTmp ¶ added in v1.1.0
MirrorTmp recursively copies the directory content of src into the hidden tmp mock directory.
func NamedDB ¶ added in v1.1.0
NamedDB returns the absolute path of a mock Bolt database with a randomly generated filename.
func RemoveTmp ¶ added in v1.1.0
RemoveTmp deletes the hidden tmp mock directory and returns the number of files deleted.
func RootDir ¶
func RootDir() string
RootDir returns the root directory of the program's source code. An empty string is returned if the directory cannot be determined.
func SensenTmp ¶ added in v1.1.0
SensenTmp generates 25 subdirectories within a hidden tmp mock directory, and copies a mock Windows/DOS .exe program file into one. The returned int is the number of bytes copied.
Types ¶
This section is empty.