-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils_test.go
65 lines (55 loc) · 1.39 KB
/
utils_test.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package tags
import (
"os"
"github.com/brianvoe/gofakeit"
"github.com/go-catupiry/catu"
"github.com/pkg/errors"
)
var appInstance catu.App
func GetAppInstance() catu.App {
if appInstance != nil {
return appInstance
}
os.Setenv("DB_URI", "file::memory:?cache=shared")
os.Setenv("DB_ENGINE", "sqlite")
// os.Setenv("LOG_QUERY", "1")
app := catu.Init(&catu.AppOptions{})
err := app.Bootstrap()
if err != nil {
panic(err)
}
// fake content stub for tests:
err = app.GetDB().AutoMigrate(
&ContentModelStub{},
&VocabularyModel{},
&TermModel{},
&ModelstermsModel{},
)
if err != nil {
panic(errors.Wrap(err, "taxonomy.GetAppInstance Error on run auto migration"))
}
return app
}
type ContentModelStub struct {
ID uint64 `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
Published bool `json:"published"`
ClickCount int64 `json:"clickCount"`
Secret string `json:"-"`
Email string `json:"email"`
Email2 string `json:"email2"`
PrivateBio string `json:"-"`
}
func GetContentModelStub() ContentModelStub {
return ContentModelStub{
// ID: gofakeit.Uint64(),
Title: gofakeit.Paragraph(1, 4, 4, " "),
Body: gofakeit.Paragraph(1, 3, 5, " "),
Published: true,
Secret: gofakeit.Word(),
Email: gofakeit.Email(),
Email2: gofakeit.Email(),
PrivateBio: gofakeit.Paragraph(1, 4, 4, ""),
}
}