repo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 1 Imported by: 0

README

This is for the Repository Test Transaction RollBack

Do not want to write a code every single time when I create a new Project.

How To Use


func Test_Rollback(t *testing.T) {
	testDB := NewTestDB(&gorm.DB{})
    
	testDB.RunWithRollback(func(tx *gorm.DB) error) error {
        // Do something with tx
        return nil
    })
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TestDB

type TestDB struct {
	// contains filtered or unexported fields
}

func (*TestDB) RunWithRollback

func (t *TestDB) RunWithRollback(f func(tx *gorm.DB) error) error

type TestDBTransaction

type TestDBTransaction interface {
	RunWithRollback(func(tx *gorm.DB) error) error
}

func NewTestDB

func NewTestDB(db *gorm.DB) TestDBTransaction

Jump to

Keyboard shortcuts

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