-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsupport_test.go
68 lines (55 loc) · 1.43 KB
/
support_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
66
67
68
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package natsdb
import (
"encoding/json"
"github.com/nats-io/go-nats"
)
// Entity : a mocked model to b used on testing
type Entity struct {
ID uint `json:"id"`
Name string `json:"name"`
}
// Find : mocked find method for testing
func (e *Entity) Find() []interface{} {
strings := []string{}
list := make([]interface{}, len(strings))
for i, s := range strings {
list[i] = s
}
return list
}
// MapInput : mocked MapInput method for testing
func (e *Entity) MapInput(body []byte) {
json.Unmarshal(body, &e)
}
// HasID : mocked HasID method for testing
func (e *Entity) HasID() bool {
return e.ID != 0
}
// LoadFromInput : mocked LoadFromInput method for testing
func (e *Entity) LoadFromInput(msg []byte) bool {
return true
}
// LoadFromInputOrFail : mocked LoadFromInputOrFail method for testing
func (e *Entity) LoadFromInputOrFail(msg *nats.Msg, h *Handler) bool {
return true
}
// Update : mocked Update method for testing
func (e *Entity) Update(body []byte) error {
stored := Entity{
ID: 22,
Name: "UPDATED",
}
e = &stored
return nil
}
// Delete : mocked Delete method for testing
func (e *Entity) Delete() error {
return nil
}
// Save : mocked Save method for testing
func (e *Entity) Save() error {
return nil
}