Skip to content

Commit 2e5388b

Browse files
test(v2): refactor and modernize tests, improve error assertions, and update mocks for v2
1 parent 901da0b commit 2e5388b

3 files changed

Lines changed: 119 additions & 127 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ As a result, Sonyflake has the following advantages and disadvantages:
1818

1919
- The lifetime (174 years) is longer than that of Snowflake (69 years)
2020
- It can work in more distributed machines (2^16) than Snowflake (2^10)
21-
- It can generate 2^8 IDs per 10 msec at most in a single machine/thread (fewer than Snowflake)
21+
- It can generate 2^8 IDs per 10 msec at most in a single instance (fewer than Snowflake)
2222

2323
However, if you want more generation rate in a single host,
24-
you can easily run multiple Sonyflake ID generators concurrently using goroutines.
24+
you can easily run multiple Sonyflake instances parallelly using goroutines.
2525

2626
Installation
2727
------------

v2/mock/sonyflake_mock.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
package mock
44

55
import (
6-
"fmt"
6+
"errors"
77
"net"
88

99
"github.com/sony/sonyflake/v2/types"
@@ -19,10 +19,12 @@ func NewSuccessfulInterfaceAddrs() types.InterfaceAddrs {
1919
}
2020
}
2121

22+
var ErrFailedToGetAddresses = errors.New("failed to get addresses")
23+
2224
// NewFailingInterfaceAddrs returns an error.
2325
func NewFailingInterfaceAddrs() types.InterfaceAddrs {
2426
return func() ([]net.Addr, error) {
25-
return nil, fmt.Errorf("test error")
27+
return nil, ErrFailedToGetAddresses
2628
}
2729
}
2830

0 commit comments

Comments
 (0)