github.com/moleculer-go/moleculer@v0.3.3/test/node_mock.go (about) 1 package test 2 3 import "time" 4 5 type NodeMock struct { 6 UpdateResult bool 7 ID string 8 IncreaseSequenceCalls int 9 HeartBeatCalls int 10 ExportAsMapResult map[string]interface{} 11 IsAvailableResult bool 12 IsExpiredResult bool 13 PublishCalls int 14 } 15 16 func (node *NodeMock) Update(id string, info map[string]interface{}) (bool, []map[string]interface{}) { 17 return node.UpdateResult, []map[string]interface{}{} 18 } 19 20 func (node *NodeMock) Unavailable() { 21 node.IsAvailableResult = false 22 } 23 func (node *NodeMock) Available() { 24 node.IsAvailableResult = true 25 } 26 27 func (node *NodeMock) GetID() string { 28 return node.ID 29 } 30 31 func (node *NodeMock) IncreaseSequence() { 32 node.IncreaseSequenceCalls++ 33 } 34 35 func (node *NodeMock) ExportAsMap() map[string]interface{} { 36 return node.ExportAsMapResult 37 } 38 func (node *NodeMock) IsAvailable() bool { 39 return node.IsAvailableResult 40 } 41 func (node *NodeMock) HeartBeat(heartbeat map[string]interface{}) { 42 node.HeartBeatCalls++ 43 } 44 func (node *NodeMock) IsExpired(timeout time.Duration) bool { 45 return node.IsExpiredResult 46 } 47 func (node *NodeMock) Publish(service map[string]interface{}) { 48 node.PublishCalls++ 49 }