Documentation ¶
Overview ¶
Package testingfiles provides primitives to use files as reference for testing
Index ¶
- func BufferCompare(got *bytes.Buffer, want string) error
- func BufferToFile(fname string, content *bytes.Buffer)
- func FileCompare(got, want string) error
- func OutputDir(s string)
- func ReadCloserCompare(got io.ReadCloser, want string) error
- func ReadCloserToFile(fname string, content io.ReadCloser) error
- func StringToFile(fname string, content []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BufferCompare ¶
BufferCompare compares the buffer to a file. If an error occurs, got file is created and the error is returned. First char in the got file is the erroneous char. If identical, nil is returned. First byte index is 0
func BufferToFile ¶
BufferToFile produces a file named fname with the content
func FileCompare ¶
FileCompare checks large outputs of a test when a file storage is more convenient or required. Names of the files to compare are passed as arguments and searched in the working directory.
func OutputDir ¶
func OutputDir(s string)
OutputDir changes the default dir to the folder where reference files (want files) are stored. Only the base of the directory is expected. If found, change default directory to it. When not found, check if ../test contains the folder.
func ReadCloserCompare ¶
func ReadCloserCompare(got io.ReadCloser, want string) error
ReadCloserCompare compares a ReadCloser to a file. If an error occurs, got file is created and the error is returned. Last read byte is absent from the got file but available in the error message. If identical, nil is returned. Logic and method are identical to *buffer.Bytes but duplicating the code avoids ReadAll. First byte index is 0 TODO Benchmark ReadAll against specific byte by byte code
func ReadCloserToFile ¶
func ReadCloserToFile(fname string, content io.ReadCloser) error
ReadCloserToFile creates a file named fname with the content
func StringToFile ¶
StringToFile produces a file named fname with the content
Types ¶
This section is empty.