📖 4 min read (~ 900 words).

File

Asserting OS Files

Assertions

GoDoc

All links point to https://pkg.go.dev/github.com/go-openapi/testify/v2

This domain exposes 6 functionalities.

DirExists

DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists.

Examples
	assertions.DirExists(t, "path/to/directory")
	success: filepath.Join(testDataPath(),"existing_dir")
	failure: filepath.Join(testDataPath(),"non_existing_dir")

FileEmpty

FileEmpty checks whether a file exists in the given path and is empty. It fails if the file is not empty, if the path points to a directory or there is an error when trying to check the file.

Examples
	assertions.FileEmpty(t, "path/to/file")
	success: filepath.Join(testDataPath(),"empty_file")
	failure: filepath.Join(testDataPath(),"existing_file")

FileExists

FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file.

Examples
	assertions.FileExists(t, "path/to/file")
	success: filepath.Join(testDataPath(),"existing_file")
	failure: filepath.Join(testDataPath(),"non_existing_file")

FileNotEmpty

FileNotEmpty checks whether a file exists in the given path and is not empty. It fails if the file is empty, if the path points to a directory or there is an error when trying to check the file.

Examples
	assertions.FileNotEmpty(t, "path/to/file")
	success: filepath.Join(testDataPath(),"existing_file")
	failure: filepath.Join(testDataPath(),"empty_file")

NoDirExists

NoDirExists checks whether a directory does not exist in the given path. It fails if the path points to an existing directory only.

Examples
	assertions.NoDirExists(t, "path/to/directory")
	success: filepath.Join(testDataPath(),"non_existing_dir")
	failure: filepath.Join(testDataPath(),"existing_dir")

NoFileExists

NoFileExists checks whether a file does not exist in a given path. It fails if the path points to an existing file only.

Examples
	assertions.NoFileExists(t, "path/to/file")
	success: filepath.Join(testDataPath(),"non_existing_file")
	failure: filepath.Join(testDataPath(),"existing_file")


Generated with github.com/go-openapi/testify/v2/codegen