template

package module
v0.0.0-...-77196fa Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2019 License: MIT Imports: 4 Imported by: 0

README

igorm-mock-template

Wrapper template for igorm

Creating your wrapper can be tiring because it has to implement 74 functions from the Gormw interface. That's why I did it for you. Fill out the methods with your code. See, for example, the First () function.

Usage

Do you remember your function which as an argument accepts any structure implementing the igorm.Gormw interface?

func getUser(db igorm.Gormw) *User {
}

You've used a wrapper that supports native gorm package functions.

db, err := igorm.Openw(dialect, path)
if err != nil {
    log.Fatal(err)
}

and you used it with your example getUser() function.

user := getUser(db)

Now you are going to make your own wrapper. This package is named template but copy/paste the code to your own package, implement functions that you need and voila.

Example with existing code
db, err := template.New("I'm happy value")
if err != nil {
    log.Fatal(err)
}

user := getUser(db)

Look for example function First(). Every call of this function on your mocked database gives:

Hey! First() method works, and the someField value is: I'm happy value

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(field string) (db igorm.Gormw, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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