mirror of
https://github.com/sony/sonyflake.git
synced 2026-11-22 08:06:28 +00:00
docs(v2/mock): improve comments and docstrings for mock implementations
This commit is contained in:
1 parent
58bcb1a582
commit
7b636bf93a
2 files changed
+10
-12
No files matched your search
@@ -1,6 +1,5 @@
|
|||||||
// Package mock offers implementations of interfaces defined in types.go
|
// Package mock offers mock implementations of interfaces defined in types.go.
|
||||||
// This allows complete control over input / output for any given method that consumes
|
// This allows complete control over input / output for any given method that consumes a given type.
|
||||||
// a given type
|
|
||||||
package mock
|
package mock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -10,7 +9,7 @@ import (
|
|||||||
"github.com/sony/sonyflake/types"
|
"github.com/sony/sonyflake/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewSuccessfulInterfaceAddrs returns a single private IP address
|
// NewSuccessfulInterfaceAddrs returns a single private IP address.
|
||||||
func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
|
func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
|
||||||
ifat := make([]net.Addr, 0, 1)
|
ifat := make([]net.Addr, 0, 1)
|
||||||
ifat = append(ifat, &net.IPNet{IP: []byte{192, 168, 0, 1}, Mask: []byte{255, 0, 0, 0}})
|
ifat = append(ifat, &net.IPNet{IP: []byte{192, 168, 0, 1}, Mask: []byte{255, 0, 0, 0}})
|
||||||
@@ -20,14 +19,14 @@ func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFailingInterfaceAddrs returns an error
|
// NewFailingInterfaceAddrs returns an error.
|
||||||
func NewFailingInterfaceAddrs() types.InterfaceAddrs {
|
func NewFailingInterfaceAddrs() types.InterfaceAddrs {
|
||||||
return func() ([]net.Addr, error) {
|
return func() ([]net.Addr, error) {
|
||||||
return nil, fmt.Errorf("test error")
|
return nil, fmt.Errorf("test error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFailingInterfaceAddrs returns an empty slice of addresses
|
// NewNilInterfaceAddrs returns an empty slice of addresses.
|
||||||
func NewNilInterfaceAddrs() types.InterfaceAddrs {
|
func NewNilInterfaceAddrs() types.InterfaceAddrs {
|
||||||
return func() ([]net.Addr, error) {
|
return func() ([]net.Addr, error) {
|
||||||
return []net.Addr{}, nil
|
return []net.Addr{}, nil
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
// Package mock offers implementations of interfaces defined in types.go
|
// Package mock offers mock implementations of interfaces defined in types.go.
|
||||||
// This allows complete control over input / output for any given method that consumes
|
// This allows complete control over input / output for any given method that consumes a given type.
|
||||||
// a given type
|
|
||||||
package mock
|
package mock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -10,7 +9,7 @@ import (
|
|||||||
"github.com/sony/sonyflake/v2/types"
|
"github.com/sony/sonyflake/v2/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewSuccessfulInterfaceAddrs returns a single private IP address
|
// NewSuccessfulInterfaceAddrs returns a single private IP address.
|
||||||
func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
|
func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
|
||||||
ifat := make([]net.Addr, 0, 1)
|
ifat := make([]net.Addr, 0, 1)
|
||||||
ifat = append(ifat, &net.IPNet{IP: []byte{192, 168, 0, 1}, Mask: []byte{255, 0, 0, 0}})
|
ifat = append(ifat, &net.IPNet{IP: []byte{192, 168, 0, 1}, Mask: []byte{255, 0, 0, 0}})
|
||||||
@@ -20,14 +19,14 @@ func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFailingInterfaceAddrs returns an error
|
// NewFailingInterfaceAddrs returns an error.
|
||||||
func NewFailingInterfaceAddrs() types.InterfaceAddrs {
|
func NewFailingInterfaceAddrs() types.InterfaceAddrs {
|
||||||
return func() ([]net.Addr, error) {
|
return func() ([]net.Addr, error) {
|
||||||
return nil, fmt.Errorf("test error")
|
return nil, fmt.Errorf("test error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFailingInterfaceAddrs returns an empty slice of addresses
|
// NewNilInterfaceAddrs returns an empty slice of addresses.
|
||||||
func NewNilInterfaceAddrs() types.InterfaceAddrs {
|
func NewNilInterfaceAddrs() types.InterfaceAddrs {
|
||||||
return func() ([]net.Addr, error) {
|
return func() ([]net.Addr, error) {
|
||||||
return []net.Addr{}, nil
|
return []net.Addr{}, nil
|
||||||
|
|||||||
Reference in new issue
Block a user