github.com/cockroachdb/pebble@v1.1.2/vfs/vfstest/vfstest.go (about) 1 // Copyright 2023 The LevelDB-Go and Pebble Authors. All rights reserved. Use 2 // of this source code is governed by a BSD-style license that can be found in 3 // the LICENSE file. 4 5 // Package vfstest provides facilities for interacting with or faking 6 // filesystems during tests and benchmarks. 7 package vfstest 8 9 import ( 10 "os" 11 12 "github.com/cockroachdb/pebble/vfs" 13 ) 14 15 // DiscardFile implements vfs.File but discards all written data and reads 16 // without mutating input buffers. 17 var DiscardFile vfs.File = (*discardFile)(nil) 18 19 type discardFile struct{} 20 21 func (*discardFile) Close() error { return nil } 22 func (*discardFile) Read(p []byte) (int, error) { return len(p), nil } 23 func (*discardFile) ReadAt(p []byte, off int64) (int, error) { return len(p), nil } 24 func (*discardFile) Write(p []byte) (int, error) { return len(p), nil } 25 func (*discardFile) WriteAt(p []byte, ofs int64) (int, error) { return len(p), nil } 26 func (*discardFile) Preallocate(offset, length int64) error { return nil } 27 func (*discardFile) Stat() (os.FileInfo, error) { return nil, nil } 28 func (*discardFile) Sync() error { return nil } 29 func (*discardFile) SyncTo(length int64) (fullSync bool, err error) { return false, nil } 30 func (*discardFile) SyncData() error { return nil } 31 func (*discardFile) Prefetch(offset int64, length int64) error { return nil } 32 func (*discardFile) Fd() uintptr { return 0 }