Codebase list golang-github-go-kit-kit / 3c0cb50
Remove mock package Marcus Olsson 7 years ago
1 changed file(s) with 0 addition(s) and 103 deletion(s). Raw diff Collapse all Expand all
+0
-103
examples/shipping/mock/mock.go less more
0 package mock
1
2 import (
3 "github.com/go-kit/kit/examples/shipping/cargo"
4 "github.com/go-kit/kit/examples/shipping/location"
5 "github.com/go-kit/kit/examples/shipping/voyage"
6 )
7
8 // CargoRepository is a mock cargo repository.
9 type CargoRepository struct {
10 StoreFn func(c *cargo.Cargo) error
11 StoreInvoked bool
12
13 FindFn func(id cargo.TrackingID) (*cargo.Cargo, error)
14 FindInvoked bool
15
16 FindAllFn func() []*cargo.Cargo
17 FindAllInvoked bool
18 }
19
20 // Store calls the StoreFn.
21 func (r *CargoRepository) Store(c *cargo.Cargo) error {
22 r.StoreInvoked = true
23 return r.StoreFn(c)
24 }
25
26 // Find calls the FindFn.
27 func (r *CargoRepository) Find(id cargo.TrackingID) (*cargo.Cargo, error) {
28 r.FindInvoked = true
29 return r.FindFn(id)
30 }
31
32 // FindAll calls the FindAllFn.
33 func (r *CargoRepository) FindAll() []*cargo.Cargo {
34 r.FindAllInvoked = true
35 return r.FindAllFn()
36 }
37
38 // LocationRepository is a mock location repository.
39 type LocationRepository struct {
40 FindFn func(location.UNLocode) (*location.Location, error)
41 FindInvoked bool
42
43 FindAllFn func() []*location.Location
44 FindAllInvoked bool
45 }
46
47 // Find calls the FindFn.
48 func (r *LocationRepository) Find(locode location.UNLocode) (*location.Location, error) {
49 r.FindInvoked = true
50 return r.FindFn(locode)
51 }
52
53 // FindAll calls the FindAllFn.
54 func (r *LocationRepository) FindAll() []*location.Location {
55 r.FindAllInvoked = true
56 return r.FindAllFn()
57 }
58
59 // VoyageRepository is a mock voyage repository.
60 type VoyageRepository struct {
61 FindFn func(voyage.Number) (*voyage.Voyage, error)
62 FindInvoked bool
63 }
64
65 // Find calls the FindFn.
66 func (r *VoyageRepository) Find(number voyage.Number) (*voyage.Voyage, error) {
67 r.FindInvoked = true
68 return r.FindFn(number)
69 }
70
71 // HandlingEventRepository is a mock handling events repository.
72 type HandlingEventRepository struct {
73 StoreFn func(cargo.HandlingEvent)
74 StoreInvoked bool
75
76 QueryHandlingHistoryFn func(cargo.TrackingID) cargo.HandlingHistory
77 QueryHandlingHistoryInvoked bool
78 }
79
80 // Store calls the StoreFn.
81 func (r *HandlingEventRepository) Store(e cargo.HandlingEvent) {
82 r.StoreInvoked = true
83 r.StoreFn(e)
84 }
85
86 // QueryHandlingHistory calls the QueryHandlingHistoryFn.
87 func (r *HandlingEventRepository) QueryHandlingHistory(id cargo.TrackingID) cargo.HandlingHistory {
88 r.QueryHandlingHistoryInvoked = true
89 return r.QueryHandlingHistoryFn(id)
90 }
91
92 // RoutingService provides a mock routing service.
93 type RoutingService struct {
94 FetchRoutesFn func(cargo.RouteSpecification) []cargo.Itinerary
95 FetchRoutesInvoked bool
96 }
97
98 // FetchRoutesForSpecification calls the FetchRoutesFn.
99 func (s *RoutingService) FetchRoutesForSpecification(rs cargo.RouteSpecification) []cargo.Itinerary {
100 s.FetchRoutesInvoked = true
101 return s.FetchRoutesFn(rs)
102 }