remove invalid uuid error

pull/314/head
Darien Raymond 8 years ago
parent d50180ebef
commit 2bc7347d6d
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -10,8 +10,6 @@ import (
var ( var (
byteGroups = []int{8, 4, 4, 4, 12} byteGroups = []int{8, 4, 4, 4, 12}
ErrInvalidID = errors.New("Invalid ID.")
) )
type UUID [16]byte type UUID [16]byte
@ -74,7 +72,7 @@ func New() *UUID {
// PraseBytes converts an UUID in byte form to object. // PraseBytes converts an UUID in byte form to object.
func ParseBytes(b []byte) (*UUID, error) { func ParseBytes(b []byte) (*UUID, error) {
if len(b) != 16 { if len(b) != 16 {
return nil, ErrInvalidID return nil, errors.New("Invalid UUID: ", b)
} }
uuid := new(UUID) uuid := new(UUID)
copy(uuid[:], b) copy(uuid[:], b)
@ -85,7 +83,7 @@ func ParseBytes(b []byte) (*UUID, error) {
func ParseString(str string) (*UUID, error) { func ParseString(str string) (*UUID, error) {
text := []byte(str) text := []byte(str)
if len(text) < 32 { if len(text) < 32 {
return nil, ErrInvalidID return nil, errors.New("Invalid UUID: ", str)
} }
uuid := new(UUID) uuid := new(UUID)

@ -18,7 +18,7 @@ func TestParseBytes(t *testing.T) {
assert.String(uuid.String()).Equals(str) assert.String(uuid.String()).Equals(str)
_, err = ParseBytes([]byte{1, 3, 2, 4}) _, err = ParseBytes([]byte{1, 3, 2, 4})
assert.Error(err).Equals(ErrInvalidID) assert.Error(err).IsNotNil()
} }
func TestParseString(t *testing.T) { func TestParseString(t *testing.T) {
@ -32,7 +32,7 @@ func TestParseString(t *testing.T) {
assert.Bytes(uuid.Bytes()).Equals(expectedBytes) assert.Bytes(uuid.Bytes()).Equals(expectedBytes)
uuid, err = ParseString("2418d087") uuid, err = ParseString("2418d087")
assert.Error(err).Equals(ErrInvalidID) assert.Error(err).IsNotNil()
uuid, err = ParseString("2418d087-648k-4990-86e8-19dca1d006d3") uuid, err = ParseString("2418d087-648k-4990-86e8-19dca1d006d3")
assert.Error(err).IsNotNil() assert.Error(err).IsNotNil()

Loading…
Cancel
Save