Table of Contents
-
files/files.go - Reads the contents of a file and checks that there was no error while reading.
Real file system:
package demo_test
import (
"os"
"github.com/itbasis/go-test-utils/v4/files"
"github.com/onsi/ginkgo/v2"
)
var _ = ginkgo.Describe("Real OS", func(){
content := files.ReadFile(os.ReadFile, "example.txt")
})
Embedded File System:
package demo_test
import (
"embed"
"github.com/itbasis/go-test-utils/v4/files"
"github.com/onsi/ginkgo/v2"
)
//go:embed example.txt
var testData embed.FS
var _ = ginkgo.Describe("Embedded FS", func(){
content := files.ReadFile(testData.ReadFile, "example.txt")
})
-
db/sql.go - Getting a DB mock and SqlMock without SqlMock options (example option: QueryMatcherOptions)
-
db/gorm.go - Getting a GORM and SqlMock instances
-
ginkgo/ginkgo.go - Adds slog support to tests and code under test
package demo_test
import (
"testing"
"github.com/itbasis/go-test-utils/v4/ginkgo"
)
func TestSuite(t *testing.T) {
ginkgo.InitGinkgoSuite(t, "Sample Suite")
}
Custom slog options
package demo_test
import (
"log/slog"
"testing"
"github.com/itbasis/go-test-utils/v4/ginkgo"
)
func TestDemoSuite(t *testing.T) {
ginkgo.InitGinkgoSuiteWithSlogOptions(t, "Sample Suite", &slog.HandlerOptions{
Level: slog.LevelDebug,
AddSource: false,
})
}