blang / Vfs
Licence: mit
Virtual filesystem library written in golang
Stars: ✭ 366
Labels
Projects that are alternatives of or similar to Vfs
Firebase Mock
Firebase mock library for writing unit tests
Stars: ✭ 319 (-12.84%)
Mutual labels: mocking
mock-inspect
Mocks network requests and allows you to make assertions about how these requests happened. Supports auto-mocking of graphQL requests given a valid schema.
Stars: ✭ 19 (-94.81%)
Mutual labels: mocking
speakeasy
A tool for creating Go web servers which can be embedded in iOS and Android apps.
Stars: ✭ 27 (-92.62%)
Mutual labels: mocking
Aioresponses
Aioresponses is a helper for mock/fake web requests in python aiohttp package.
Stars: ✭ 278 (-24.04%)
Mutual labels: mocking
Powermock
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.
Stars: ✭ 3,708 (+913.11%)
Mutual labels: mocking
automock
A library for testing classes with auto mocking capabilities using jest-mock-extended
Stars: ✭ 26 (-92.9%)
Mutual labels: mocking
Unmock Plugin
Gradle plugin to be used in combination with the new unit testing feature of the Gradle Plugin / Android Studio to use real classes for e.g. SparseArray.
Stars: ✭ 304 (-16.94%)
Mutual labels: mocking
TestBox
TestBox is a next generation testing framework for ColdFusion (CFML) that is based on BDD (Behavior Driven Development) for providing a clean obvious syntax for writing tests. It also includes MockBox, our mocking and stubbing framework.
Stars: ✭ 54 (-85.25%)
Mutual labels: mocking
cypress-auto-stub-example
Example project to demonstrate how to record/replay API with Cypress.
Stars: ✭ 52 (-85.79%)
Mutual labels: mocking
Mockqueryable
Moking Entity Framework Core operations such ToListAsync, FirstOrDefaultAsync etc
Stars: ✭ 281 (-23.22%)
Mutual labels: mocking
dummyjdbc
dummyjdbc answers database requests with dummy data to be independent of an existing database.
Stars: ✭ 20 (-94.54%)
Mutual labels: mocking
Apitest
A simple and extensible behavioural testing library for Go. You can use api test to simplify REST API, HTTP handler and e2e tests.
Stars: ✭ 317 (-13.39%)
Mutual labels: mocking
xf-application-mocks
Contains lightweight substitutes for SAP applications to ease the development and testing of extension and integration scenarios. In conjunction with SAP Business Technology Platform, kyma runtime, the efficient implementation of application extensions is supported without the need for real SAP applications being accessible during development.
Stars: ✭ 21 (-94.26%)
Mutual labels: mocking
Pook
HTTP traffic mocking and testing made simple in Python
Stars: ✭ 257 (-29.78%)
Mutual labels: mocking
React Mock
Declarative mocks for React state and global APIs
Stars: ✭ 355 (-3.01%)
Mutual labels: mocking
vfs for golang
vfs is library to support virtual filesystems. It provides basic abstractions of filesystems and implementations, like OS
accessing the file system of the underlying OS and memfs
a full filesystem in-memory.
Usage
$ go get github.com/blang/vfs
Note: Always vendor your dependencies or fix on a specific version tag.
import github.com/blang/vfs
// Create a vfs accessing the filesystem of the underlying OS
var osfs vfs.Filesystem = vfs.OS()
osfs.Mkdir("/tmp", 0777)
// Make the filesystem read-only:
osfs = vfs.ReadOnly(osfs) // Simply wrap filesystems to change its behaviour
// os.O_CREATE will fail and return vfs.ErrReadOnly
// os.O_RDWR is supported but Write(..) on the file is disabled
f, _ := osfs.OpenFile("/tmp/example.txt", os.O_RDWR, 0)
// Return vfs.ErrReadOnly
_, err := f.Write([]byte("Write on readonly fs?"))
if err != nil {
fmt.Errorf("Filesystem is read only!\n")
}
// Create a fully writable filesystem in memory
mfs := memfs.Create()
mfs.Mkdir("/root", 0777)
// Create a vfs supporting mounts
// The root fs is accessing the filesystem of the underlying OS
fs := mountfs.Create(osfs)
// Mount a memfs inside /memfs
// /memfs may not exist
fs.Mount(mfs, "/memfs")
// This will create /testdir inside the memfs
fs.Mkdir("/memfs/testdir", 0777)
// This would create /tmp/testdir inside your OS fs
// But the rootfs `osfs` is read-only
fs.Mkdir("/tmp/testdir", 0777)
Check detailed examples below. Also check the GoDocs.
Why should I use this lib?
- Only Stdlib
- (Nearly) Fully tested (Coverage >90%)
- Easy to create your own filesystem
- Mock a full filesystem for testing (or use included
memfs
) - Compose/Wrap Filesystems
ReadOnly(OS())
and write simple Wrappers - Many features, see GoDocs and examples below
Features and Examples
- OS Filesystem support
- ReadOnly Wrapper
- DummyFS for quick mocking
- MemFS - full in-memory filesystem
- MountFS - support mounts across filesystems
Current state: ALPHA
While the functionality is quite stable and heavily tested, interfaces are subject to change.
You need more/less abstraction? Let me know by creating a Issue, thank you.
Motivation
I simply couldn't find any lib supporting this wide range of variation and adaptability.
Contribution
Feel free to make a pull request. For bigger changes create a issue first to discuss about it.
License
See LICENSE file.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].