-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (40 loc) · 1.16 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//go:generate sqlboiler --wipe crdb
package main
import (
"database/sql"
"github.com/davecgh/go-spew/spew"
"github.com/volatiletech/null"
"themontem/factory/factory"
"themontem/factory/models"
_ "github.com/lib/pq"
)
func main() {
dbInstance, err := sql.Open("postgres", "host=192.168.56.101 port=36257 user=root dbname=startrek sslmode=disable")
if err != nil {
panic(err)
}
factory.DB = dbInstance
episode := factory.NewEpisode(true, func(g *factory.EpisodeGenerator) {
g.Season = func() null.Int64 {
return null.NewInt64(5, false)
}
})
quote := factory.NewQuote(true, func(qg *factory.QuoteGenerator) {
qg.Episode = func(dbInsert bool, opts ...factory.EpisodeOption) *models.Episode {
return factory.NewEpisode(true, func(eg *factory.EpisodeGenerator) {
eg.Num = func() null.Int64 {
return null.Int64From(100)
}
})
}
})
quoteGenerator := factory.NewQuoteGenerator(func(generator *factory.QuoteGenerator) {
generator.Characters = func() null.String {
return null.StringFrom("themontem")
}
})
q1 := factory.NewQuote(true, factory.LoadGenerator(quoteGenerator))
spew.Dump(episode)
spew.Dump(quote)
spew.Dump(q1)
}