mocks

package
v1.999.0-test Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package mocks provides some common utilities to test the fuse functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertTree

func AssertTree(t testing.TB, tree UploadTree, root string)

AssertTree checks an actual FS structure against some reference in-memory fixture folder description

func EmptyBundle

func EmptyBundle(ev mocks.TestEnv) *core.Bundle

EmptyBundle produces an initialized bundle with proper staging and context, but no bundle ID yet

func FakeBundle

func FakeBundle(ev mocks.TestEnv) *core.Bundle

FakeBundle produce some fake bundle structure for this test environment

func NewErrPutCaFs

func NewErrPutCaFs(t testing.TB, blob storage.Store, leafSize uint32) (cafs.Fs, error)

NewErrPutCaFs produces a mocked up cafs.Fs used to simulate a Put error

func TestInspectDir

func TestInspectDir(t testing.TB, pth string)

TestInspectDir is a debug helper to inspect the various temp mounts before removal

Types

type UploadFileTest

type UploadFileTest struct {
	// contains filtered or unexported fields
}

UploadFileTest describes a mocked up uploaded file fixture

type UploadTree

type UploadTree []*UploadFileTest

UploadTree define a mocked up file hierarchy

func MakeTestUploadTree

func MakeTestUploadTree() UploadTree

MakeTestUploadTree defines a default fixture to test a hierarchy of files, with different sizes

func PopulateFS

func PopulateFS(t testing.TB, mountPath string, fixtureBuilders ...func() UploadTree) UploadTree

PopulateFS populates the file tree fixture, with some random data in mocked up files. It prepares the expected locations relative to mountPath.

* write files to the mounted filesystem, with random data. * the returned structure keeps data and checksums to make further assertions

func PopulateFSWithDirs

func PopulateFSWithDirs(t testing.TB, mountPath string, withFile bool, fixtureBuilders ...func() UploadTree) UploadTree

PopulateFSWithDirs is the same as TestPopulateFS, but ignores size and just create directories instead of files.

Notes

Bugs

  • spotted in rw mount. If we put all files with same content, the deduplication ends up with an error on commit... => have to randomize for now data := []byte(`not empty`)

Jump to

Keyboard shortcuts

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