forked from genevieve/leftovers
/
page.go
63 lines (60 loc) · 1.21 KB
/
page.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
package fakes
import "sync"
type Page struct {
GetBodyCall struct {
sync.Mutex
CallCount int
Returns struct {
Interface interface {
}
}
Stub func() interface {
}
}
IsEmptyCall struct {
sync.Mutex
CallCount int
Returns struct {
Bool bool
Error error
}
Stub func() (bool, error)
}
NextPageURLCall struct {
sync.Mutex
CallCount int
Returns struct {
String string
Error error
}
Stub func() (string, error)
}
}
func (f *Page) GetBody() interface {
} {
f.GetBodyCall.Lock()
defer f.GetBodyCall.Unlock()
f.GetBodyCall.CallCount++
if f.GetBodyCall.Stub != nil {
return f.GetBodyCall.Stub()
}
return f.GetBodyCall.Returns.Interface
}
func (f *Page) IsEmpty() (bool, error) {
f.IsEmptyCall.Lock()
defer f.IsEmptyCall.Unlock()
f.IsEmptyCall.CallCount++
if f.IsEmptyCall.Stub != nil {
return f.IsEmptyCall.Stub()
}
return f.IsEmptyCall.Returns.Bool, f.IsEmptyCall.Returns.Error
}
func (f *Page) NextPageURL() (string, error) {
f.NextPageURLCall.Lock()
defer f.NextPageURLCall.Unlock()
f.NextPageURLCall.CallCount++
if f.NextPageURLCall.Stub != nil {
return f.NextPageURLCall.Stub()
}
return f.NextPageURLCall.Returns.String, f.NextPageURLCall.Returns.Error
}