feat: add gomock testing
This commit is contained in:
parent
e39ea9e48f
commit
86da64fa41
1
go.mod
1
go.mod
|
@ -4,6 +4,7 @@ go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/emirpasic/gods v1.18.1
|
github.com/emirpasic/gods v1.18.1
|
||||||
|
github.com/golang/mock v1.6.0
|
||||||
github.com/google/go-cmp v0.6.0
|
github.com/google/go-cmp v0.6.0
|
||||||
github.com/multiformats/go-multibase v0.2.0
|
github.com/multiformats/go-multibase v0.2.0
|
||||||
github.com/vmihailenco/msgpack/v5 v5.4.1
|
github.com/vmihailenco/msgpack/v5 v5.4.1
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
|
//go:generate mockgen -source=meta.go -destination=../mocks/interfaces/meta.go -package=interfaces
|
||||||
|
|
||||||
type Metadata interface {
|
type Metadata interface {
|
||||||
ToJson() map[string]interface{}
|
ToJson() map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockgen -source=node.go -destination=../mocks/interfaces/node.go -package=interfaces
|
||||||
|
|
||||||
type Node interface {
|
type Node interface {
|
||||||
Services() Services
|
Services() Services
|
||||||
HashQueryRoutingTable() structs.Map
|
HashQueryRoutingTable() structs.Map
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockgen -source=p2p.go -destination=../mocks/interfaces/p2p.go -package=interfaces
|
||||||
|
|
||||||
type P2PService interface {
|
type P2PService interface {
|
||||||
Node() Node
|
Node() Node
|
||||||
Peers() structs.Map
|
Peers() structs.Map
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
|
//go:generate mockgen -source=service.go -destination=../mocks/interfaces/service.go -package=interfaces
|
||||||
|
|
||||||
type Service interface {
|
type Service interface {
|
||||||
Node() Node
|
Node() Node
|
||||||
Start() error
|
Start() error
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package interfaces
|
package interfaces
|
||||||
|
|
||||||
|
//go:generate mockgen -source=storage.go -destination=../mocks/interfaces/storage.go -package=interfaces
|
||||||
|
|
||||||
type StorageLocation interface {
|
type StorageLocation interface {
|
||||||
BytesURL() string
|
BytesURL() string
|
||||||
OutboardBytesURL() string
|
OutboardBytesURL() string
|
||||||
|
|
|
@ -2,6 +2,8 @@ package interfaces
|
||||||
|
|
||||||
import "github.com/vmihailenco/msgpack/v5"
|
import "github.com/vmihailenco/msgpack/v5"
|
||||||
|
|
||||||
|
//go:generate mockgen -source=vote.go -destination=../mocks/interfaces/vote.go -package=interfaces
|
||||||
|
|
||||||
type NodeVotes interface {
|
type NodeVotes interface {
|
||||||
msgpack.CustomEncoder
|
msgpack.CustomEncoder
|
||||||
msgpack.CustomDecoder
|
msgpack.CustomDecoder
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"github.com/vmihailenco/msgpack/v5"
|
"github.com/vmihailenco/msgpack/v5"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:generate mockgen -source=incoming_message.go -destination=../mocks/base/incoming_message.go -package=base
|
||||||
|
|
||||||
type IncomingMessage interface {
|
type IncomingMessage interface {
|
||||||
HandleMessage(node interfaces.Node, peer net.Peer, verifyId bool) error
|
HandleMessage(node interfaces.Node, peer net.Peer, verifyId bool) error
|
||||||
SetIncomingMessage(msg IncomingMessage)
|
SetIncomingMessage(msg IncomingMessage)
|
||||||
|
|
Loading…
Reference in New Issue