✨ Add Random Generator
This commit is contained in:
parent
5c1132e414
commit
1677a692d1
8 changed files with 142 additions and 53 deletions
|
|
@ -4,7 +4,6 @@ import (
|
|||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
|
@ -61,24 +60,3 @@ func TestMultiGeneratorInOrderMissing(t *testing.T) {
|
|||
assert.Zero(t, st)
|
||||
assert.ErrorIs(t, err, ErrMissingGenerators)
|
||||
}
|
||||
|
||||
func TestUUID(t *testing.T) {
|
||||
st, err := UUID()(nil)
|
||||
assert.NoError(t, err)
|
||||
_, parseErr := uuid.Parse(st)
|
||||
assert.NoError(t, parseErr)
|
||||
}
|
||||
|
||||
type badRead struct{}
|
||||
|
||||
func (badRead) Read([]byte) (int, error) {
|
||||
return 0, errors.New("sorry")
|
||||
}
|
||||
|
||||
func TestUUIDFail(t *testing.T) {
|
||||
uuid.SetRand(badRead{})
|
||||
defer uuid.SetRand(nil)
|
||||
|
||||
_, err := UUID()(nil)
|
||||
assert.Equal(t, errors.New("sorry"), err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue