https://github.com/qbart/expecto
Mini testing library for Go based on stdlib. Fails early with colored output.
https://github.com/qbart/expecto
assertions go testing
Last synced: 10 months ago
JSON representation
Mini testing library for Go based on stdlib. Fails early with colored output.
- Host: GitHub
- URL: https://github.com/qbart/expecto
- Owner: qbart
- License: mit
- Created: 2025-04-04T23:34:54.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-04-05T12:05:35.000Z (about 1 year ago)
- Last Synced: 2025-04-10T00:06:41.918Z (about 1 year ago)
- Topics: assertions, go, testing
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# expecto

Idea is to provide simple wrapper for testing library that immediately exits when assertion fails
and prints colored output with diff.
Most matchers follow the pattern: `matcher(t *testing.T, msg string, value any, expected any)`
## Matchers
```go
expecto.NoErr(t, "parsing config", err)
expecto.Eq(t, "number of files", len(c.Files), 1)
expecto.Eq(t, "number of chunks", len(c.Files[0].Chunks), 2)
expecto.Eq(t, "number of migrations", len(c.Files[0].Migrations), 1)
expecto.Nil(t, "transaction", c.Transaction)
expecto.Contains(t, "notification message", str, "error message")
expecto.Map(t, anyMap).HasKey("has cache key", "cache-1")
```
See files for the full list of assertions.
## Temporary file system
Random dir in system TempDir is created.
```go
fs, dir, cleanup := expecto.TempFS(
"src/path.txt",
"content1",
"src/b/2.txt",
"content2,
)
defer cleanup()
```