redistest

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2023 License: MIT Imports: 10 Imported by: 0

README

redistest

import "github.com/induzo/gocom/database/redistest"

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

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

func (*DockertestWrapper) Purge
func (dw *DockertestWrapper) Purge()

Generated by gomarkdoc

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()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL