Skip to content

qbart/expecto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

expecto

example spec

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

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.

fs, dir, cleanup := expecto.TempFS(
   "src/path.txt",
   "content1",
   "src/b/2.txt",
   "content2,
)
defer cleanup()

About

Mini testing library for Go based on stdlib. Fails early with colored output.

Topics

Resources

License

Stars

Watchers

Forks

Languages