-
Notifications
You must be signed in to change notification settings - Fork 0
/
stubs.go
75 lines (58 loc) · 1.24 KB
/
stubs.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
66
67
68
69
70
71
72
73
74
75
package console
type Stubs struct {
}
func (r Stubs) Request() string {
return `package requests
import (
"gopkg.in/go-mixed/framework/contracts/http"
"gopkg.in/go-mixed/framework/contracts/validation"
)
type DummyRequest struct {
DummyField
}
func (r *DummyRequest) Authorize(ctx http.Context) error {
return nil
}
func (r *DummyRequest) Rules() map[string]string {
return map[string]string{}
}
func (r *DummyRequest) Messages() map[string]string {
return map[string]string{}
}
func (r *DummyRequest) Attributes() map[string]string {
return map[string]string{}
}
func (r *DummyRequest) PrepareForValidation(data validation.Data) error {
return nil
}
`
}
func (r Stubs) Controller() string {
return `package controllers
import (
"gopkg.in/go-mixed/framework/contracts/http"
)
type DummyController struct {
//Dependent services
}
func NewDummyController() *DummyController {
return &DummyController{
//Inject services
}
}
func (r *DummyController) Index(ctx http.Context) {
}
`
}
func (r Stubs) Middleware() string {
return `package middleware
import (
contractshttp "gopkg.in/go-mixed/framework/contracts/http"
)
func DummyMiddleware() contractshttp.Middleware {
return func(ctx contractshttp.Context) {
ctx.Request().Next()
}
}
`
}