Skip to content

kacperjurak/igorm-mock-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages