os

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package provides wrapper aound os module for purpose of testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultOS

type DefaultOS struct {
}

DefaultOS is a default implementation of OS interface which proxies everything to standard lib.

func (DefaultOS) AppendFile

func (DefaultOS) AppendFile(name string) (OSFile, error)

appendFile returns a file opened for write with cursor positioned at the end of file.

func (DefaultOS) CreateIfMissing

func (DefaultOS) CreateIfMissing(name string) error

createIfMissing tries create file if it's not there yet, otherwise no op.

func (DefaultOS) Open

func (DefaultOS) Open(name string) (OSFile, error)

open is a direct proxy to os.Open

type FakeFile

type FakeFile struct {
	io.Reader
	Content string
}

FakeFile implements OSFile.

func (FakeFile) Close

func (f FakeFile) Close() error

Close is a no op to satisfy OSFile.

func (FakeFile) Seek

func (f FakeFile) Seek(int64, int) (int64, error)

func (*FakeFile) Size

func (f *FakeFile) Size() int64

func (*FakeFile) Stat

func (f *FakeFile) Stat() (os.FileInfo, error)

func (FakeFile) Sync

func (f FakeFile) Sync() error

func (FakeFile) Truncate

func (f FakeFile) Truncate(size int64) error

func (*FakeFile) Write

func (f *FakeFile) Write(p []byte) (ret int, err error)

Write is a method of FakeFile that records all data it receives.

type FakeFileInfo

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

func (FakeFileInfo) IsDir

func (f FakeFileInfo) IsDir() bool

func (FakeFileInfo) ModTime

func (f FakeFileInfo) ModTime() time.Time

func (FakeFileInfo) Mode

func (f FakeFileInfo) Mode() os.FileMode

func (FakeFileInfo) Name

func (f FakeFileInfo) Name() string

func (FakeFileInfo) Size

func (f FakeFileInfo) Size() int64

func (FakeFileInfo) Sys

func (f FakeFileInfo) Sys() interface{}

type FakeOS

type FakeOS struct {
	FakeData string
	FakeFile *FakeFile
}

FakeOS implements OS.

func (*FakeOS) AppendFile

func (o *FakeOS) AppendFile(name string) (OSFile, error)

appendFile returns a FakeFile implementation that will record any data it receives for later analisis.

func (*FakeOS) CreateIfMissing

func (o *FakeOS) CreateIfMissing(name string) error

createIfMissing No op in tests.

func (FakeOS) Open

func (o FakeOS) Open(name string) (OSFile, error)

open returns a FakeFile stuffed with fake data

type OS

type OS interface {
	Open(name string) (OSFile, error)
	AppendFile(name string) (OSFile, error)
	CreateIfMissing(name string) error
}

OS interface is a facade to standard lib os.

type OSFile

type OSFile interface {
	io.Reader
	io.Writer
	io.Closer
	io.Seeker
	Stat() (os.FileInfo, error)
	Truncate(size int64) error
	Sync() error
}

OSFile interface is a facade to os.File

Jump to

Keyboard shortcuts

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