Categorygithub.com/itbasis/go-test-utils

# README

= test utils :toc: macro

image:https://img.shields.io/github/go-mod/go-version/itbasis/go-test-utils[GitHub go.mod Go version] image:https://img.shields.io/badge/godoc-reference-blue.svg[link=https://pkg.go.dev/github.com/itbasis/go-test-utils] image:https://img.shields.io/github/v/release/itbasis/go-test-utils[GitHub Release] https://goreportcard.com/report/github.com/itbasis/go-test-utils[image:https://goreportcard.com/badge/github.com/itbasis/go-test-utils[Go Report Card]]

toc::[]

== Install module

go get -u github.com/itbasis/go-test-utils/v4

== File utils

  • link:files/files.go[] - Reads the contents of a file and checks that there was no error while reading.

Real file system: [source,go]

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: [source,go]

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") })

== Database utils

== Ginkgo utils

  • link:ginkgo/ginkgo.go[] - Adds slog support to tests and code under test

[source,go]

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

[source,go]

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, }) }

# Packages

No description provided by the author