forked from sebastienfr/handsongo
/
spirit-dao-mock.go
72 lines (59 loc) · 2.01 KB
/
spirit-dao-mock.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
package dao
import (
"github.com/Sfeir/handsongo/model"
"time"
)
// safety check
var _ SpiritDAO = (*SpiritDAOMock)(nil)
// MockedSpirit is the spirit returned by this mocked interface
var MockedSpirit = model.Spirit{
Name: "Caroni",
Distiller: "Caroni",
Bottler: "Velier",
Country: "Trinidad",
Composition: "Molasse",
SpiritType: model.TypeRhum,
Age: 15,
BottlingDate: time.Date(2015, 01, 01, 0, 0, 0, 0, time.UTC),
Score: 8.5,
Comment: "heavy tire taste",
}
// SpiritDAOMock is the mocked implementation of the SpiritDAO
type SpiritDAOMock struct {
}
// NewSpiritDAOMock creates a new SpiritDAO with a mocked implementation
func NewSpiritDAOMock() SpiritDAO {
return &SpiritDAOMock{}
}
// GetSpiritByID returns a spirit by its ID
func (s *SpiritDAOMock) GetSpiritByID(ID string) (*model.Spirit, error) {
return &MockedSpirit, nil
}
// GetAllSpirits returns all spirits with paging capability
func (s *SpiritDAOMock) GetAllSpirits(start, end int) ([]model.Spirit, error) {
return []model.Spirit{MockedSpirit}, nil
}
// GetSpiritsByName returns all spirits by name
func (s *SpiritDAOMock) GetSpiritsByName(name string) ([]model.Spirit, error) {
return []model.Spirit{MockedSpirit}, nil
}
// GetSpiritsByType returns all spirits by type
func (s *SpiritDAOMock) GetSpiritsByType(spiritType string) ([]model.Spirit, error) {
return []model.Spirit{MockedSpirit}, nil
}
// GetSpiritsByTypeAndScore returns all spirits by type and score greater than parameter
func (s *SpiritDAOMock) GetSpiritsByTypeAndScore(spiritType string, score uint8) ([]model.Spirit, error) {
return []model.Spirit{MockedSpirit}, nil
}
// SaveSpirit saves the spirit
func (s *SpiritDAOMock) SaveSpirit(spirit *model.Spirit) error {
return nil
}
// UpsertSpirit updates or creates a spirit
func (s *SpiritDAOMock) UpsertSpirit(ID string, spirit *model.Spirit) (bool, error) {
return true, nil
}
// DeleteSpirit deletes a spirits by its ID
func (s *SpiritDAOMock) DeleteSpirit(ID string) error {
return nil
}