Database unit testing for Golang.
package main
import (
"context""fmt""github.com/go-rel/rel/where""github.com/go-rel/reltest"
)
typeMoviestruct {
IDintTitlestring
}
funcmain() {
var (
repo=reltest.New()
)
// Mock queryrepo.ExpectFind(where.Eq("id", 1)).Result(Movie{ID: 1, Title: "Golang"})
// Application codevarmovieMovierepo.MustFind(context.Background(), &movie, where.Eq("id", 1))
fmt.Println(movie.Title)
// Output: Golang
}More Examples:
- gin-example - Todo Backend using Gin and REL
- go-todo-backend - Todo Backend using Chi and REL
Released under the MIT License
