Documentation
¶
Overview ¶
Package mock provides simulated database and bucket functions for unit testing.
Index ¶
- Constants
- Variables
- func Bucket(t *testing.T, i int) (string, error)
- func CSV(t *testing.T) string
- func Create(t *testing.T) string
- func Database(t *testing.T) (*bolt.DB, string)
- func Export(t *testing.T, i int) string
- func Extension(t *testing.T, ext string) string
- func Item(t *testing.T, i int) string
- func ItemSum(t *testing.T, item int) string
- func MirrorData(t *testing.T) string
- func NamedDB(t *testing.T) string
- func Open(t *testing.T, path string) (*bolt.DB, string)
- func RemoveTmp(t *testing.T, path string) int
- func RootDir(t *testing.T) string
- func SensenTmp(t *testing.T, path string) int64
- func Sum(t *testing.T, item int, b [32]byte) bool
- func TempDir(t *testing.T) string
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") )
var ErrRuntime = errors.New("runtime caller failed")
Functions ¶
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 MirrorData ¶ added in v1.2.0
MirrorData 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 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.