# README
Assert with spf13/afero
The logic is shamelessly copy from stretchr/testify/assert with some salt and pepper.
Prerequisites
Go >= 1.17
Install
go get go.nhat.io/aferoassert
Usage
package mypackage_test
import (
"testing"
"github.com/spf13/afero"
"go.nhat.io/aferoassert"
)
func TestTreeEqual_Success(t *testing.T) {
osFs := afero.NewOsFs()
tree := `
- workflows:
- golangci-lint.yaml
- test.yaml 'perm:"0644"'
`
aferoassert.DirExists(t, osFs, ".github")
aferoassert.YAMLTreeEqual(t, osFs, tree, ".github")
}
Donation
If this project help you reduce time to develop, you can give me a cup of coffee :)
Paypal donation
or scan this

# Functions
DirExists checks whether a directory exists in the given path.
Exists checks whether a file or directory exists in the given path.
FileContent checks whether a file content is as expected or not.
FileContentRegexp checks whether a file content matches the expectation or not.
FileExists checks whether a file exists in the given path.
FileModeFromUint64 returns *os.FileMode from an uint64.
FileModePtr returns pointer to file mode.
NoDirExists checks whether a directory does not exist in the given path.
NoExists checks whether a file does not exist in a given path.
NoFileExists checks whether a file does not exist in a given path.
Perm checks whether a path has the expected permission or not.
TreeContains checks whether a directory contains a file tree or not.
TreeEqual checks whether a directory is the same as the expectation or not.
YAMLTreeContains checks whether a directory contains a file tree or not.
YAMLTreeEqual checks whether a directory is the same as the expectation or not.
# Variables
ErrFileNameEmpty indicates that the file name is empty.
ErrInvalidFileMode indicates that the file mode is invalid.
ErrInvalidFileTreeFormat indicates that format of the file tree is invalid and could not be parsed.
# Interfaces
TestingT is an interface wrapper around *testing.T.