Documentation ¶
Overview ¶
Package redistest implements dockertest with redis for testing.
Use case in TestMain
var dockertest *redistest.DockertestWrapper func TestMain(m *testing.M) { dockertest = redistest.New() code := m.Run() dockertest.Purge() os.Exit(code) } func TestFunc(t *testing.T) { t.Parallel() repo := NewRepo(dockertest.RedisAddr) tests := []struct{ name string }{} for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() ... }) } } func TestRun(t *testing.T) { t.Parallel() tests := []struct{ name string }{} for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() repo := NewRepo(dockertest.RedisAddr) ... }) } }
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DockertestWrapper ¶
type DockertestWrapper struct { DockertestPool *dockertest.Pool DockertestResource *dockertest.Resource RedisAddr string }
func New ¶
func New() *DockertestWrapper
Example ¶
package main import ( "github.com/induzo/gocom/database/redistest" ) func main() { //nolint: testableexamples // redistest no output dockertest := redistest.New() // repo := NewRepo(dockertest.RedisAddr) // do something... dockertest.Purge() }
Output:
func (*DockertestWrapper) Purge ¶
func (dw *DockertestWrapper) Purge()
Click to show internal directories.
Click to hide internal directories.